Skip to content

Add contrib v3 migration and update contrib tooling#222

Merged
ReneWerner87 merged 2 commits into
masterfrom
codex/2025-11-03-07-44-56
Nov 21, 2025
Merged

Add contrib v3 migration and update contrib tooling#222
ReneWerner87 merged 2 commits into
masterfrom
codex/2025-11-03-07-44-56

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

@ReneWerner87 ReneWerner87 commented Nov 3, 2025

Summary

  • add a migration that rewrites github.com/gofiber/contrib imports and go.mod entries to the v3 module path and cover it with tests
  • update contrib refresh logic and tests to use the new github.com/gofiber/contrib/v3 prefix
  • align the monitor import migration and integration tests with the contrib v3 packages

Testing

  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_6907e5507e1c83269ab613f940ed562c

Summary by CodeRabbit

  • New Features

    • Added automatic migration for GoFiber contrib packages to v3, updating imports and module references across projects and tooling messages.
  • Tests

    • Added verification tests covering migration behavior, replace-directives, and idempotency to ensure safe repeated runs.
  • Chores

    • Normalized contrib path handling and updated related prompts and messages to reflect the v3 module prefix.

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 3, 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 new v3 migration that rewrites Go Fiber contrib package references to the v3 module path and registers that migration in the V3 migration list; updates related import-migration logic, helper constants, tests, and test expectations.

Changes

Cohort / File(s) Summary
Migration Registration
cmd/internal/migrations/lists.go
Inserts v3migrations.MigrateContribPackages into the V3 Functions list for the >=2.0.0-0 → <4.0.0-0 migration range
Contrib Packages Migration Implementation
cmd/internal/migrations/v3/contrib_packages.go
New MigrateContribPackages(cmd *cobra.Command, cwd string, _, _ *semver.Version) error that updates import paths and go.mod entries from github.com/gofiber/contrib/... to github.com/gofiber/contrib/v3/..., skipping already-versioned paths and vendor dirs; reads/writes files and reports when changes occur
Contrib Packages Tests
cmd/internal/migrations/v3/contrib_packages_test.go
Adds tests: basic migration, migration with replace directive, and idempotency (no-op on already-migrated code)
Monitor Import Migration Update
cmd/internal/migrations/v3/monitor_import.go, cmd/internal/migrations/v3/monitor_import_test.go
Changes replacement target to github.com/gofiber/contrib/v3/monitor and updates test expectations accordingly
Third-party Prefixes & Usage
cmd/third_party.go, cmd/third_party_test.go
Introduces contribModulePrefix and contribRepoPrefix and updates internal string construction, prompts, URL and pseudo-version derivation to use .../contrib/v3/...; tests updated to expect v3 paths
Test Expectation Update
cmd/migrate_test.go
Updates TestMain to expect github.com/gofiber/contrib/v3/monitor in sample code/go.mod

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Migration Runner
    participant Migrate as MigrateContribPackages
    participant Transformer as ChangeFileContent
    participant Walker as Filesystem Walk
    participant FS as File I/O

    Caller->>Migrate: invoke with cwd
    Migrate->>Transformer: scan .go files, replace imports\n(contrib/... → contrib/v3/...), skip versioned paths
    Transformer-->>Migrate: report if imports changed
    Migrate->>Walker: walk directories for go.mod (skip vendor)
    Walker->>FS: read go.mod
    FS-->>Walker: contents
    Walker->>Walker: replace contrib module paths → contrib/v3
    Walker->>FS: write go.mod if changed
    FS-->>Walker: write result
    Walker-->>Migrate: report if go.mod changed
    alt any changes
        Migrate->>Caller: print "Migrating contrib packages"
    else
        Migrate->>Caller: no output
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing attention:
    • Regex/path handling in go.mod replacements and hasVersionPrefix correctness to avoid double-migration
    • File I/O and vendor-directory skipping during walk
    • Tests covering replace-directive preservation and idempotency

Possibly related PRs

Poem

🐇 Hopping through imports, I nudge each line,

contrib becomes v3, tidy and fine.
I skip the vendor, avoid double-tread,
write go.mod softly, then nod my head.
A little rabbit archivist, marching code ahead.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 clearly and accurately summarizes the main changes: adding a contrib v3 migration and updating contrib tooling across the codebase.
Description check ✅ Passed The description provides a clear summary of changes, includes testing steps, and references a task link, but lacks detailed problem explanation as suggested by the template.
✨ 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-03-07-44-56

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a65406 and eb1af46.

📒 Files selected for processing (1)
  • cmd/internal/migrations/v3/contrib_packages.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/recipes PR: 0
File: :0-0
Timestamp: 2024-11-26T20:05:15.793Z
Learning: For future contributions to the `gofiber/recipes` repository, ensure that the tasks outlined in `.github/CONTRIBUTING.md` are incorporated, including creating a new directory without a "fiber" prefix, adding a `README.md` with Docusaurus metadata, and updating the overview by running `make generate`.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
🧬 Code graph analysis (1)
cmd/internal/migrations/v3/contrib_packages.go (1)
cmd/internal/helpers.go (1)
  • ChangeFileContent (54-110)
⏰ 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, macos-latest)
  • GitHub Check: Build (1.25.x, ubuntu-latest)
  • GitHub Check: Build (1.25.x, macos-13)
  • GitHub Check: Build (1.25.x, windows-latest)
🔇 Additional comments (4)
cmd/internal/migrations/v3/contrib_packages.go (4)

17-25: LGTM! Regex patterns and constants are well-defined.

The regular expressions correctly handle both import statements (with quotes/backticks) and go.mod entries. The patterns appropriately match contrib paths and will work with typical Go module syntax.


30-45: LGTM! Import migration logic is sound.

The function correctly processes import statements, preserving the quote style and avoiding double-migration of already-versioned paths through the hasVersionPrefix check.


47-92: LGTM! Excellent improvement on file permission preservation.

The go.mod migration logic correctly walks the filesystem, skips vendor directories, and processes module files. The use of info.Mode().Perm() on line 84 properly preserves only the permission bits when writing the updated file, which addresses the previous review comment about maintaining original file permissions.

The hasVersionPrefix check on line 76 ensures idempotency by preventing migration of already-versioned paths.


102-114: LGTM! Version prefix detection is robust.

The helper function correctly identifies version prefixes (e.g., v2/, v3/, v10/) by verifying the pattern starts with 'v', followed by one or more digits, and either terminates or continues with '/'. This prevents false positives and ensures accurate detection of already-versioned module paths.


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.

@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 essential updates to the project's migration and tooling infrastructure to support the transition of github.com/gofiber/contrib packages to their v3 module path. The changes ensure that both Go import statements within source files and module requirements in go.mod files are correctly updated, facilitating a smooth upgrade path for users of the gofiber/cli tool. This effort maintains compatibility and streamlines the process of adopting the new v3 versions of contrib packages.

Highlights

  • New Contrib V3 Migration: A new migration has been added to automatically rewrite github.com/gofiber/contrib imports and go.mod entries to use the v3 module path, complete with comprehensive tests.
  • Updated Contrib Tooling: The existing contrib refresh logic and associated tests have been updated to correctly utilize the new github.com/gofiber/contrib/v3 prefix, ensuring compatibility with the latest module structure.
  • Monitor Import Alignment: The monitor import migration and its integration tests have been aligned to correctly reference the v3 packages for github.com/gofiber/contrib/monitor.
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.

@github-actions github-actions Bot added ✏️ Feature New feature or request 🧹 Updates labels Nov 3, 2025
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/third_party.go
Comment on lines +30 to +33
const (
contribModulePrefix = "github.com/gofiber/contrib/v3/"
contribRepoPrefix = "gofiber/contrib/v3"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use correct repo path when generating contrib pseudo versions

The new contribRepoPrefix constant now includes /v3, but refreshContrib passes this value to pseudoVersionFromHash when a hash is provided. pseudoVersionFromHash constructs the GitHub API URL from that prefix, so the request targets https://api.github.com/repos/gofiber/contrib/v3/..., which does not exist—the repository is still gofiber/contrib. As a result, running the contrib refresh command with --hash will fail to fetch commit metadata and cannot compute pseudo versions. Keep the repository prefix as gofiber/contrib while using the /v3 suffix only for import paths.

Useful? React with 👍 / 👎.

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 migration for gofiber/contrib packages to the v3 module path and updates the related tooling. The changes are well-structured, and the new migration logic is covered by a good set of tests, including checks for idempotency. The updates to the contrib refresh logic and monitor middleware are consistent with the migration. I've found one issue regarding file permission preservation which I've commented on. Overall, this is a solid contribution.

Comment thread cmd/internal/migrations/v3/contrib_packages.go
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner November 21, 2025 09:35
@ReneWerner87 ReneWerner87 requested review from efectn, gaby and sixcolors and removed request for a team November 21, 2025 09:35
@ReneWerner87 ReneWerner87 merged commit 063da1b into master Nov 21, 2025
12 of 13 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-11-03-07-44-56 branch November 21, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant