Skip to content

Add migrator for swagger packages#226

Merged
ReneWerner87 merged 2 commits into
masterfrom
codex/2025-11-29-15-54-44
Nov 30, 2025
Merged

Add migrator for swagger packages#226
ReneWerner87 merged 2 commits into
masterfrom
codex/2025-11-29-15-54-44

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

@ReneWerner87 ReneWerner87 commented Nov 29, 2025

Summary

  • add a migrator to move Fiber swagger imports to contrib/v3 equivalents and ensure swagger aliases are applied
  • update go.mod entries for swagger packages using cached contrib version lookups
  • register the new migrator before existing contrib updates and cover it with idempotent tests

Testing

  • make lint
  • make test

Codex Task

Summary by CodeRabbit

  • New Features

    • Automated migration for Swagger-related packages during upgrades (rewrites imports and updates module requirements).
    • Improved version resolution for the migration tool with caching and a configurable fetcher (includes a restore mechanism).
  • Tests

    • Added comprehensive tests for Swagger migration, including idempotency and various integration scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@ReneWerner87 ReneWerner87 requested a review from a team as a code owner November 29, 2025 15:54
@ReneWerner87 ReneWerner87 requested review from gaby and sixcolors and removed request for a team November 29, 2025 15:54
@ReneWerner87 ReneWerner87 requested a review from efectn November 29, 2025 15:54
@github-actions github-actions Bot added the ✏️ Feature New feature or request label Nov 29, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new migration tool designed to streamline the update process for projects using Fiber's Swagger-related packages. It automates the transition of old Swagger import paths and 'go.mod' dependencies to their new 'gofiber/contrib/v3' equivalents, ensuring consistency and proper versioning. This change simplifies maintenance and helps users keep their projects aligned with the latest Fiber ecosystem structure.

Highlights

  • New Migrator for Swagger Packages: A new migrator has been added to automatically update Fiber projects that use Swagger packages.
  • Import Path Updates: The migrator updates old import paths like 'github.com/gofiber/contrib/swagger' and 'github.com/gofiber/swagger' to their new 'gofiber/contrib/v3/swaggo' and 'gofiber/contrib/v3/swaggerui' equivalents.
  • go.mod Dependency Management: It automatically updates 'go.mod' entries for these Swagger packages, fetching their latest 'v3' versions from the Go proxy to ensure up-to-date dependencies.
  • Swagger Alias Application: The migrator ensures that the 'swagger' alias is correctly applied to the migrated import statements.
  • Idempotent Testing: Comprehensive idempotent tests have been included to verify that running the migrator multiple times on the same codebase yields consistent results without unintended changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a migrator for Fiber swagger packages, updating import paths and go.mod entries to their new contrib/v3 equivalents. It also adds a utility for fetching module versions from the Go proxy, complete with caching and test support. The changes are well-structured and include idempotent tests. My review identified a critical issue in the import rewriting logic that could break user code by incorrectly applying an alias. I have also noted a few medium-severity issues in the new version-fetching utility concerning concurrency, error handling, and performance best practices.

Comment thread cmd/internal/migrations/v3/swagger_packages.go
Comment thread cmd/internal/migrations/v3/contrib_versions.go
Comment thread cmd/internal/migrations/v3/contrib_versions.go Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 29, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a v3 migration that rewrites Swagger-related imports and updates go.mod entries, plus a cached, thread-safe Contrib v3 version lookup with a pluggable fetcher and restore function. Tests exercise migration behavior, idempotency, and import preservation.

Changes

Cohort / File(s) Summary
Migration Registration
cmd/internal/migrations/lists.go
Registers v3migrations.MigrateSwaggerPackages in the v3 migrations list.
Version Lookup & Caching
cmd/internal/migrations/v3/contrib_versions.go
Adds mutex-protected cache, singleflight dedupe, HTTP Go-proxy fetcher (5s timeout), pluggable SetContribV3VersionFetcher and restore function, and JSON parsing of Version.
Swagger Migration Logic
cmd/internal/migrations/v3/swagger_packages.go
New migration entry MigrateSwaggerPackages plus helpers to scan workspace, rewrite Swagger imports via AST, resolve target module versions using contribV3Version, and update go.mod require/replace directives.
Swagger Migration Tests
cmd/internal/migrations/v3/swagger_packages_test.go
Tests for swaggo and fiber/swagger migrations, mocked version fetcher, idempotency checks, import-preservation cases, and assertion of logged migration message.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as CLI Migration
    participant Scanner as Workspace Scanner
    participant Fetcher as contribV3Version
    participant Cache as Version Cache / singleflight
    participant Files as File Reader/Writer
    participant GoMod as go.mod Updater

    User->>CLI: run v3 migration
    CLI->>Scanner: scan workspace for go.mod and imports
    Scanner->>Scanner: detect swagger dependencies
    alt swagger dependency found
        Scanner->>Fetcher: request target module version
        Fetcher->>Cache: check cache / singleflight
        alt cache miss
            Cache->>Fetcher: perform HTTP GET to Go proxy
            Fetcher-->>Cache: return version
        end
        Cache-->>Scanner: return resolved version
        Scanner->>Files: rewrite Go imports (AST)
        Files-->>Scanner: write updated sources
        Scanner->>GoMod: update require/replace lines with new path/version
        GoMod-->>Scanner: write updated go.mod
        Scanner-->>CLI: changes made
    else no swagger found
        Scanner-->>CLI: no changes
    end
    CLI-->>User: finish
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay attention to concurrency and cache invalidation in contrib_versions.go (mutex + singleflight + restore).
  • Verify AST import rewriting edge cases and alias insertion in swagger_packages.go.
  • Review regex-based go.mod rewriting for correctness across require and replace blocks.
  • Inspect tests for proper isolation and deterministic version fetcher behavior.

Possibly related PRs

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

🐰
I hopped through imports, nibbled the old,
Cached versions snug in a mutex fold.
go.mod renewed, imports set free,
A little migration dance—hippity-honky! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add migrator for swagger packages' clearly and specifically summarizes the main change—adding a new migrator for swagger packages.
Description check ✅ Passed The PR description provides a clear summary of changes, testing instructions, and a reference link, though it doesn't follow the detailed template structure with explicit problem/rationale section.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-11-29-15-54-44

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
cmd/internal/migrations/v3/contrib_versions.go (2)

20-38: Potential race condition: double fetch on cache miss.

When multiple goroutines call contribV3Version for the same uncached module simultaneously, they all pass the cache check, release the lock, and call fetcher(module) concurrently. This results in redundant HTTP requests and duplicated work.

Consider using sync.Map with LoadOrStore or a singleflight.Group to deduplicate in-flight requests.

+import "golang.org/x/sync/singleflight"
+
+var contribV3VersionGroup singleflight.Group
+
 func contribV3Version(module string) (string, error) {
 	contribV3VersionMu.Lock()
 	if v, ok := contribV3VersionCache[module]; ok {
 		contribV3VersionMu.Unlock()
 		return v, nil
 	}
-	fetcher := contribV3VersionFetcher
 	contribV3VersionMu.Unlock()
 
-	v, err := fetcher(module)
-	if err != nil {
-		return "", err
+	result, err, _ := contribV3VersionGroup.Do(module, func() (interface{}, error) {
+		contribV3VersionMu.Lock()
+		fetcher := contribV3VersionFetcher
+		contribV3VersionMu.Unlock()
+		return fetcher(module)
+	})
+	if err != nil {
+		return "", err
 	}
+	v := result.(string)
 
 	contribV3VersionMu.Lock()
 	contribV3VersionCache[module] = v
 	contribV3VersionMu.Unlock()
 	return v, nil
 }

50-50: Reuse a shared http.Client instead of creating one per request.

Creating a new http.Client{} for each call prevents connection reuse. Consider using a package-level client or http.DefaultClient.

-	client := &http.Client{}
-	res, err := client.Do(req)
+	res, err := http.DefaultClient.Do(req)
cmd/internal/migrations/v3/swagger_packages.go (2)

73-76: Consider removing unused d.Info() call.

The info variable is only used to retrieve info.Mode().Perm() at line 115. You could simplify by using os.Stat(path) only when writing is needed, or use a fixed permission like 0o644 since go.mod files typically have standard permissions.

-		info, err := d.Info()
-		if err != nil {
-			return fmt.Errorf("stat %s: %w", path, err)
-		}
-
 		b, err := os.ReadFile(path) // #nosec G304 -- reading module files
 		if err != nil {
 			return fmt.Errorf("read %s: %w", path, err)
 		}
 ...
-		if err := os.WriteFile(path, []byte(updated), info.Mode().Perm()); err != nil {
+		if err := os.WriteFile(path, []byte(updated), 0o644); err != nil {
 			return fmt.Errorf("write %s: %w", path, err)
 		}

179-189: Regex replacement applies twice for new paths, which is redundant but harmless.

reRequireOld replaces oldPath with newPath, then reRequireNew immediately replaces newPath with newPath again. The second replacement is a no-op when the version already matches but incurs unnecessary regex overhead.

Consider combining the patterns or conditionally skipping the second replacement if oldPath != newPath was already applied.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72f3762 and 06551af.

📒 Files selected for processing (4)
  • cmd/internal/migrations/lists.go (1 hunks)
  • cmd/internal/migrations/v3/contrib_versions.go (1 hunks)
  • cmd/internal/migrations/v3/swagger_packages.go (1 hunks)
  • cmd/internal/migrations/v3/swagger_packages_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
cmd/internal/migrations/lists.go (1)
cmd/internal/migrations/v3/swagger_packages.go (1)
  • MigrateSwaggerPackages (30-53)
cmd/internal/migrations/v3/swagger_packages.go (1)
cmd/internal/helpers.go (1)
  • ChangeFileContent (54-110)
cmd/internal/migrations/v3/swagger_packages_test.go (2)
cmd/internal/migrations/v3/contrib_versions.go (1)
  • SetContribV3VersionFetcher (80-92)
cmd/internal/migrations/v3/swagger_packages.go (1)
  • MigrateSwaggerPackages (30-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build (1.25.x, ubuntu-latest)
  • GitHub Check: Build (1.25.x, windows-latest)
  • GitHub Check: Build (1.25.x, macos-latest)
  • GitHub Check: Build (1.25.x, macos-13)
🔇 Additional comments (6)
cmd/internal/migrations/v3/contrib_versions.go (1)

78-92: LGTM!

The SetContribV3VersionFetcher function correctly handles mutex locking, cache reset, and returns a proper restore function. The design supports clean test isolation via t.Cleanup(restore).

cmd/internal/migrations/lists.go (1)

58-59: LGTM!

The placement of MigrateSwaggerPackages before MigrateContribPackages is correct. This ensures swagger-specific imports and go.mod entries are migrated before the general contrib package migration runs.

cmd/internal/migrations/v3/swagger_packages.go (2)

145-159: Forcing swagger alias may overwrite intentional custom aliases.

When the import already has a non-empty alias (e.g., swag "github.com/gofiber/contrib/v3/swaggo"), the current logic skips overwriting. However, for new paths (lines 145-146), it still adds the swagger alias if missing, which is correct. The logic looks sound.

LGTM! The alias enforcement ensures consistent usage across migrated codebases.


30-53: LGTM!

The MigrateSwaggerPackages function cleanly orchestrates import rewriting and go.mod migration, with proper error propagation and conditional logging when changes occur.

cmd/internal/migrations/v3/swagger_packages_test.go (2)

3-14: I'll help you verify the review comment about missing helper functions in the test file. Let me search for these functions to confirm whether they're actually referenced and where they're defined.
<function_calls>

#!/bin/bash

First, let's see the full content of the test file to check for function references

cat cmd/internal/migrations/v3/swagger_packages_test.go


</function_calls>
<function_calls>

#!/bin/bash

Search for the three helper functions in the migrations/v3 directory

echo "=== Searching for writeTempFile ==="
rg -n "writeTempFile" cmd/internal/migrations/v3/ --type go

echo -e "\n=== Searching for newCmd ==="
rg -n "newCmd" cmd/internal/migrations/v3/ --type go

echo -e "\n=== Searching for readFile ==="
rg -n "readFile" cmd/internal/migrations/v3/ --type go


</function_calls>


112-159: I'll verify the idempotency test expectation by examining the detection logic and caching behavior. Let me search for the relevant code.
<function_calls>

find . -type f -name "*.go" | grep -E "(swagger|v3)" | head -20

</function_calls>

Let me search for the migration logic:
<function_calls>

#!/bin/bash
rg -n "needsSwaggo|needsSwaggerUI" --type go -A 2 -B 2


</function_calls>

Let me also look for the MigrateSwaggerPackages function and cache implementation:
<function_calls>

#!/bin/bash
rg -n "contribV3Version|SetContribV3VersionFetcher" --type go -A 3 -B 3


</function_calls>

Let me search more broadly in the migrations directory:
<function_calls>

#!/bin/bash
fd "swagger" cmd/internal/migrations/v3 --type f


</function_calls>

Let me look at the test file and surrounding context:
<function_calls>

#!/bin/bash
cat -n cmd/internal/migrations/v3/swagger_packages_test.go | head -180


</function_calls>

Now let me find the implementation file:
<function_calls>

#!/bin/bash
ls -la cmd/internal/migrations/v3/ | grep -E ".go$"


</function_calls>

Let me examine the swagger_packages.go file:
<function_calls>

#!/bin/bash
wc -l cmd/internal/migrations/v3/swagger_packages.go


</function_calls>

<function_calls>

#!/bin/bash
cat -n cmd/internal/migrations/v3/swagger_packages.go


</function_calls>

Perfect! Now let me look for how the modules are detected and the cache mechanism:
<function_calls>

#!/bin/bash
rg -n "var contribV3Version" --type go -A 5 -B 5


</function_calls>

Let me search more specifically in the v3 directory:
<function_calls>

#!/bin/bash
rg -n "contribV3Version|SetContribV3VersionFetcher" cmd/internal/migrations/v3/ --type go -A 5


</function_calls>

Let me check what files exist in the v3 migrations directory:
<function_calls>

#!/bin/bash
ls -la cmd/internal/migrations/v3/


</function_calls>

Let me examine the main.go file:
<function_calls>

#!/bin/bash
cat -n cmd/internal/migrations/v3/main.go


</function_calls>

Now let me trace through the logic. Let me look for where contribV3Version is used:
<function_calls>

#!/bin/bash
rg -n "contribV3VersionFetcher|contribV3Version" cmd/internal/migrations/ --type go -B 2 -A 2


</function_calls>

Let me search in the entire codebase:
<function_calls>

#!/bin/bash
rg -n "contribV3Version" --type go -B 2 -A 2


</function_calls>

Let me look at the internal migrations directory structure:
<function_calls>

#!/bin/bash
find cmd/internal/migrations -type f -name "*.go" | sort


</function_calls>

Let me check the v3 directory more carefully:
<function_calls>

#!/bin/bash
wc -l cmd/internal/migrations/v3/*.go


</function_calls>

Let me read helper.go:
<function_calls>

#!/bin/bash
cat -n cmd/internal/migrations/v3/helper.go


</function_calls>

Perfect! Now let me trace the logic. Let me look at how the modules are detected in MigrateSwaggerPackages:
<function_calls>

#!/bin/bash
sed -n '1,150p' cmd/internal/migrations/v3/swagger_packages.go | cat -n


</function_calls>

<function_calls>

#!/bin/bash
sed -n '151,300p' cmd/internal/migrations/v3/swagger_packages.go | cat -n


</function_calls>

Now I understand the flow. Let me trace through the test logic more carefully by examining what happens:

Let me verify the exact cache logic:
<function_calls>

#!/bin/bash
sed -n '20,45p' cmd/internal/migrations/v3/helper.go | cat -n


</function_calls>

Excellent! Now I have all the information I need. Let me verify my understanding with one more check:
<function_calls>

#!/bin/bash

Verify that needsSwaggo and needsSwaggerUI are based on both imports AND go.mod

sed -n '40,90p' cmd/internal/migrations/v3/swagger_packages.go | cat -n


</function_calls>

Perfect! Now I have all the information needed.

Now I have all the information to provide my final response. The verification shows that the review comment's concern is not valid.

The test expectation of calls == 2 is correct; the cache persists across both migration runs.

The contribV3Version is a package-scoped map variable in helper.go (line 3-4) that persists throughout the test. When getContribV3Version() is called (line 25-35 of helper.go), it checks the cache first; if a version is already cached, it returns without calling the fetcher function.

In the test:

  • First call: Both swaggo and swaggerui are needed (swaggo is imported in the file, swaggerui is listed in go.mod), so both versions are fetched via the fetcher → calls = 2
  • Second call: Both modules are still needed, but their versions are already in the cache, so the fetcher is not called → calls remains 2

The detection logic correctly identifies both modules as needed (lines 82-106 of swagger_packages.go): modules are considered needed if they appear in imports OR in go.mod.

Comment thread cmd/internal/migrations/v3/contrib_versions.go
Comment thread cmd/internal/migrations/v3/swagger_packages.go Outdated
@ReneWerner87 ReneWerner87 added the 🤖 Dependencies Pull requests that update a dependency file label Nov 30, 2025
@ReneWerner87
Copy link
Copy Markdown
Member Author

/gemini review
@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 30, 2025

@ReneWerner87: I'll review the changes in this PR right away.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Hello @ReneWerner87,

Thanks for the prompt! I've completed my review of your pull request. This is a well-structured and thoroughly tested migration, and I appreciate the attention to detail.

Summary of Review

This pull request introduces a robust migration tool for updating Fiber projects that use Swagger-related packages. The core functionality involves:

  • Import Path Rewriting: Leveraging Go's ast package to accurately update import paths from old github.com/gofiber/contrib/swagger and github.com/gofiber/swagger to their gofiber/contrib/v3/swaggo and gofiber/contrib/v3/swaggerui equivalents, including adding the swagger alias where necessary.
  • go.mod Dependency Management: Utilizing regular expressions to update require and replace directives in go.mod files, ensuring dependencies point to the correct v3 versions.
  • Efficient Version Fetching: Implementing a cached and thread-safe mechanism using sync.Mutex and golang.org/x/sync/singleflight to fetch the latest v3 module versions from proxy.golang.org.
  • Comprehensive Testing: Including idempotent tests that verify the migration can be run multiple times without unintended side effects, and that existing correct imports are preserved.

Overall, the changes are well-implemented and demonstrate a good understanding of Go's tooling for code manipulation and dependency management. The tests are particularly strong, covering various scenarios and ensuring the reliability of the migration.

Review Comments

I have a few minor suggestions, primarily focused on maintainability and best practices, which you can find in the inline comments. These are mostly low severity and do not block merging.

Style Guide

For this review, I've adhered to common Go programming practices and conventions, as outlined in Effective Go and Go CodeReviewComments.

Let me know if you have any questions!


Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cmd/internal/migrations/v3/swagger_packages_test.go (1)

162-205: Strict no-op preservation test is useful; fetcher setup could be DRY’d up

The exact equality checks on both source and go.mod plus empty log output give a strong guarantee that already‑correct contrib/v3 usage is left untouched. That’s a good complement to the broader idempotency test.

If you ever touch this area again, you might consider a tiny helper to reduce the repeated SetContribV3VersionFetcher/t.Cleanup boilerplate across the four tests (e.g., passing in a map of module→version). Not urgent, but could tighten things up.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06551af and 8d4e0c1.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (3)
  • cmd/internal/migrations/v3/contrib_versions.go (1 hunks)
  • cmd/internal/migrations/v3/swagger_packages.go (1 hunks)
  • cmd/internal/migrations/v3/swagger_packages_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/internal/migrations/v3/contrib_versions.go
  • cmd/internal/migrations/v3/swagger_packages.go
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/internal/migrations/v3/swagger_packages_test.go (2)
cmd/internal/migrations/v3/contrib_versions.go (1)
  • SetContribV3VersionFetcher (95-107)
cmd/internal/migrations/v3/swagger_packages.go (1)
  • MigrateSwaggerPackages (30-53)
🔇 Additional comments (4)
cmd/internal/migrations/v3/swagger_packages_test.go (4)

1-19: Good external test structure and shared module constants

Using package v3_test with shared swaggoModule/swaggerUIModule constants gives nice black‑box coverage of the migration API across all tests. No issues here.


21-64: Contrib → v3/swaggo migration test looks solid

This test cleanly validates the contrib/swagger → contrib/v3/swaggo flow including aliasing, go.mod version/replace updates, and the migration log line. It’s a good end‑to‑end check of both import rewriting and module migration.


66-110: Fiber Swagger → contrib/v3/swaggerui coverage is comprehensive

The test fully exercises the fiber/swagger migration path: import re‑targeting with alias preservation, go.mod update to contrib/v3/swaggerui at the fetched version, and confirmation of the user‑visible log. Nicely complements the first test.


112-160: Idempotency and contrib version cache behavior well covered

This test nicely proves that:

  • Running the migration multiple times is a no‑op when things are already on contrib/v3.
  • No extra log noise is produced on no‑change runs.
  • The contrib v3 version lookup is cached across runs (one real fetch per module, as asserted by calls == 2).

Good guard against regressions in both the migrator and the caching layer.

@ReneWerner87 ReneWerner87 merged commit 0faa079 into master Nov 30, 2025
15 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-11-29-15-54-44 branch November 30, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex 🤖 Dependencies Pull requests that update a dependency file ✏️ Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant