Skip to content

Conversation

@ReneWerner87
Copy link
Member

@ReneWerner87 ReneWerner87 commented Nov 30, 2025

Extend the filesystem middleware migration to handle NotFoundFile:

  • Comment out NotFoundFile configuration (deprecated)
  • Add TODO comment referencing NotFoundHandler (fiber.Handler)
  • Ensure idempotent migration (no duplicate comments on re-run)

Changes:

  • Add regex pattern to detect and comment NotFoundFile
  • Only apply migration if TODO comment not already present
  • Add test for NotFoundFile migration
  • Add test for idempotency to prevent duplicate migrations

Migration transforms:
NotFoundFile: "index.html", To:
// TODO: Migrate to NotFoundHandler (fiber.Handler) - NotFoundFile is deprecated // NotFoundFile: "index.html",

Summary by CodeRabbit

  • Chores
    • Added migration that deprecates NotFoundFile by commenting it out and inserting a TODO guiding transition to NotFoundHandler, avoiding duplicate markers.
  • Tests
    • Added tests verifying migration behavior and idempotency so repeated runs do not duplicate migration notes.

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

Extend the filesystem middleware migration to handle NotFoundFile:
- Comment out NotFoundFile configuration (deprecated)
- Add TODO comment referencing NotFoundHandler (fiber.Handler)
- Ensure idempotent migration (no duplicate comments on re-run)

Changes:
- Add regex pattern to detect and comment NotFoundFile
- Only apply migration if TODO comment not already present
- Add test for NotFoundFile migration
- Add test for idempotency to prevent duplicate migrations

Migration transforms:
  NotFoundFile: "index.html",
To:
  // TODO: Migrate to NotFoundHandler (fiber.Handler) - NotFoundFile is deprecated
  // NotFoundFile: "index.html",
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner November 30, 2025 15:57
@ReneWerner87 ReneWerner87 requested review from efectn, gaby and sixcolors and removed request for a team November 30, 2025 15:57
@gemini-code-assist
Copy link
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 an important enhancement to the existing migration script for the filesystem middleware. It specifically addresses the deprecation of the NotFoundFile configuration by automatically commenting it out and inserting a TODO comment, directing users towards the recommended NotFoundHandler. A key aspect of this change is the implementation of idempotency, ensuring that the migration can be run multiple times without introducing redundant modifications.

Highlights

  • NotFoundFile Migration: Extends the filesystem middleware migration to specifically handle the deprecated NotFoundFile configuration.
  • Deprecation Handling: Comments out the NotFoundFile configuration and adds a TODO comment guiding users to migrate to NotFoundHandler.
  • Idempotency: Ensures the migration process is idempotent, preventing duplicate comments or changes if the migration is run multiple times.
  • Testing: Adds new test cases to verify the correct migration of NotFoundFile and to confirm the idempotency of the migration process.
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
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 extends the filesystem middleware migration to handle the deprecated NotFoundFile configuration. The changes correctly comment out the NotFoundFile field and add a TODO for manual migration, with an idempotency check to prevent duplicate changes. The accompanying tests are thorough, covering both the migration logic and its idempotency. My review includes a couple of suggestions for improvement: one for performance by optimizing regex compilation, and another for using the standard library to simplify the test code.

Remove extra whitespace from assertion to match goimports formatted output
@coderabbitai
Copy link

coderabbitai bot commented Nov 30, 2025

Warning

Rate limit exceeded

@ReneWerner87 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 123ef46 and 51bdb84.

📒 Files selected for processing (2)
  • cmd/internal/migrations/v3/filesystem_middleware.go (2 hunks)
  • cmd/internal/migrations/v3/filesystem_middleware_test.go (2 hunks)

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 migration handling to deprecate NotFoundFile in the filesystem middleware migration by commenting out occurrences and inserting a TODO advising migration to NotFoundHandler, with guards to avoid duplicating the migration note.

Changes

Cohort / File(s) Summary
Migration Logic
cmd/internal/migrations/v3/filesystem_middleware.go
Adds handling for NotFoundFile: replaces occurrences with commented lines that include a TODO to migrate to NotFoundHandler, and avoids inserting duplicate migration notes.
Migration Tests
cmd/internal/migrations/v3/filesystem_middleware_test.go
Adds two tests: one asserting NotFoundFile is commented with a TODO and FS migration performed; another asserting idempotency (migration is stable across repeated runs). Adds countOccurrences helper used in tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect string-replacement logic for edge cases (whitespace variants, multiple occurrences).
  • Verify idempotency assertion and test helper correctness.

Possibly related PRs

  • #3006: Related changes touching filesystem→static migration and handling of filesystem options including NotFoundFile.

Suggested labels

✏️ Feature, codex

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

🐰 I hopped through files with gentle care,
Commented NotFoundFile to leave a spare,
A TODO tucked where handlers shall grow,
Run twice—still tidy, steady, and slow,
Hop onward, migration done—hooray! 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 accurately describes the main change: extending filesystem middleware migration to handle NotFoundFile deprecation and migration to NotFoundHandler.
Description check ✅ Passed The description is comprehensive and covers the problem, solution, and implementation details, though it could better explain the context/motivation before diving into technical details.

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

@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 (2)
cmd/internal/migrations/v3/filesystem_middleware.go (1)

37-44: Consider a more precise idempotency check.

The current check uses strings.Contains(content, "TODO: Migrate to NotFoundHandler") on the entire file content. While this works for typical cases, it could skip legitimate NotFoundFile migrations if that TODO text exists elsewhere in the file (e.g., in an unrelated comment or string literal).

A more robust approach would be to check if each specific NotFoundFile line already has the TODO comment immediately above it, rather than checking the entire file.

For example, you could modify the regex to detect already-migrated patterns:

 // Handle NotFoundFile migration - comment it out and add TODO for NotFoundHandler
-// Only migrate if not already migrated (check for TODO comment)
-if !strings.Contains(content, "TODO: Migrate to NotFoundHandler") {
-	reNotFoundFile := regexp.MustCompile(`(?m)^(\s*)(NotFoundFile:\s*[^,\n]+)(,?)`)
-	content = reNotFoundFile.ReplaceAllString(content,
-		`$1// TODO: Migrate to NotFoundHandler (fiber.Handler) - NotFoundFile is deprecated
+// Skip lines that already have the TODO comment above them
+reNotFoundFile := regexp.MustCompile(`(?m)^(\s*)(NotFoundFile:\s*[^,\n]+)(,?)`)
+content = reNotFoundFile.ReplaceAllStringFunc(content, func(match string) string {
+	// Check if this specific match is already preceded by the TODO
+	idx := strings.Index(content, match)
+	if idx > 0 {
+		prefix := content[:idx]
+		if strings.HasSuffix(strings.TrimRight(prefix, "\n"), "TODO: Migrate to NotFoundHandler (fiber.Handler) - NotFoundFile is deprecated") {
+			return match // Already migrated, leave as is
+		}
+	}
+	// Apply migration
+	re := regexp.MustCompile(`^(\s*)(NotFoundFile:\s*[^,\n]+)(,?)`)
+	return re.ReplaceAllString(match, `$1// TODO: Migrate to NotFoundHandler (fiber.Handler) - NotFoundFile is deprecated
 $1// $2$3`)
-}
+})
cmd/internal/migrations/v3/filesystem_middleware_test.go (1)

121-129: Consider using the built-in strings.Count function.

The Go standard library provides strings.Count which does exactly what this helper function does, making this implementation redundant.

Apply this diff to use the standard library function:

-// Helper function to count occurrences of a substring
-func countOccurrences(str, substr string) int {
-	count := 0
-	for i := 0; i <= len(str)-len(substr); i++ {
-		if str[i:i+len(substr)] == substr {
-			count++
-		}
-	}
-	return count
-}

Then update the usage in the test:

 	// Verify the TODO comment is only present once
-	assert.Equal(t, 1, countOccurrences(secondContent, "TODO: Migrate to NotFoundHandler"))
+	assert.Equal(t, 1, strings.Count(secondContent, "TODO: Migrate to NotFoundHandler"))
 	// Verify the NotFoundFile comment is only present once
-	assert.Equal(t, 1, countOccurrences(secondContent, "// NotFoundFile:"))
+	assert.Equal(t, 1, strings.Count(secondContent, "// NotFoundFile:"))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 339389a and 3696cf2.

📒 Files selected for processing (2)
  • cmd/internal/migrations/v3/filesystem_middleware.go (1 hunks)
  • cmd/internal/migrations/v3/filesystem_middleware_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/internal/migrations/v3/filesystem_middleware_test.go (1)
cmd/internal/migrations/v3/filesystem_middleware.go (1)
  • MigrateFilesystemMiddleware (14-57)
⏰ 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-13)
  • GitHub Check: Build (1.25.x, macos-latest)
  • GitHub Check: Build (1.25.x, ubuntu-latest)
  • GitHub Check: Build (1.25.x, windows-latest)
🔇 Additional comments (2)
cmd/internal/migrations/v3/filesystem_middleware_test.go (2)

44-77: LGTM!

The test thoroughly validates the NotFoundFile migration behavior, checking that the field is commented out, the TODO marker is added, and the static middleware migration is applied correctly.


79-118: Excellent idempotency test!

This test effectively validates that the migration can be run multiple times without duplicating comments or producing different results, which is essential for a reliable migration tool.

Performance improvements:
- Move all regex compilation from closure to package-level variables
- Avoids repeated compilation overhead when processing multiple files
- Compiled regexes are now reused across all file migrations

Code quality improvements:
- Replace custom countOccurrences helper with strings.Count
- More idiomatic and efficient standard library usage
- Remove unnecessary helper function

This addresses code review feedback for better performance and idiomatic Go.
@ReneWerner87 ReneWerner87 merged commit 26ff457 into master Nov 30, 2025
13 of 14 checks passed
@ReneWerner87 ReneWerner87 deleted the claude/migrate-static-middleware-01REo5PC9G8oEaRfwGrLPR8a branch November 30, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants