Skip to content

Fix middleware locals migration idempotency#227

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

Fix middleware locals migration idempotency#227
ReneWerner87 merged 2 commits into
masterfrom
codex/2025-11-29-15-55-06

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

@ReneWerner87 ReneWerner87 commented Nov 29, 2025

Summary

  • prevent the middleware locals migration from appending multiple trailing true values
  • add regression coverage to ensure rerunning the migration keeps outputs stable

Testing

  • make lint
  • make test

Codex Task

Summary by CodeRabbit

  • Chores

    • Migration updated to robustly handle repeated runs without producing duplicate trailing annotations.
  • Tests

    • Added an idempotence test to confirm migrations apply once and leave no extra duplicates on subsequent runs.

✏️ 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:55
@ReneWerner87 ReneWerner87 requested review from efectn, gaby and sixcolors and removed request for a team November 29, 2025 15:55
@ReneWerner87 ReneWerner87 added codex ☢️ Bug Something isn't working labels 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 addresses an idempotency issue within the middleware locals migration. Previously, rerunning the migration could lead to redundant true values being appended. The changes modify the migration logic to prevent this behavior and introduce a new test to ensure the migration consistently produces the same output regardless of how many times it is applied, thereby improving its reliability and predictability.

Highlights

  • Migration Idempotency: The middleware locals migration has been updated to prevent it from appending multiple trailing true values when run more than once, ensuring stable outputs.
  • Regression Coverage: A new test case has been added to specifically verify the idempotency of the middleware locals migration, confirming that rerunning the migration does not introduce 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 correctly addresses the idempotency issue in the middleware locals migration by updating the regular expression to handle cases where the migration has already been run. The addition of a regression test is excellent for ensuring this behavior is maintained. I've suggested a small improvement to the new test to make it even more robust by comparing the file state directly.

Comment thread cmd/internal/migrations/v3/middleware_locals_test.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

Widened the regex in MigrateMiddlewareLocals to accept repeated trailing ", true" after short variable declarations and added a test ensuring the migration is idempotent when run multiple times.

Changes

Cohort / File(s) Summary
Regex pattern widening
cmd/internal/migrations/v3/middleware_locals.go
Expanded the reComma regex to include (?:\s*,\s*true)*, allowing optional repeated , true occurrences when matching short variable declarations. Replacement unchanged.
Idempotency test
cmd/internal/migrations/v3/middleware_locals_test.go
Added Test_MigrateMiddlewareLocals_Idempotent to verify the migration produces the same output when run twice and does not accumulate extra , true tokens.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the regex handles edge cases (spacing, multiple existing , true) and does not overmatch unrelated commas.
  • Confirm the replacement logic remains correct when matches already include one or more , true.
  • Review the new test to ensure it asserts both first-run changes and true idempotence on the second run.

Possibly related PRs

Poem

🐰
A hop, a tweak, the regex learns to star,
No doubling booleans when migrations are.
Run once, run twice — the code stays true,
A tidy change from this rabbit to you. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 directly addresses the main change: fixing idempotency in the middleware locals migration by preventing duplicate 'true' values.
Description check ✅ Passed The description covers the problem being solved and testing performed, though it lacks commit message emoji formatting specified in 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-29-15-55-06

📜 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 f1498eb and edbd8fd.

📒 Files selected for processing (1)
  • cmd/internal/migrations/v3/middleware_locals_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/internal/migrations/v3/middleware_locals_test.go (1)
cmd/internal/migrations/v3/middleware_locals.go (1)
  • MigrateMiddlewareLocals (33-201)
⏰ 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, windows-latest)
  • GitHub Check: Build (1.25.x, ubuntu-latest)
🔇 Additional comments (1)
cmd/internal/migrations/v3/middleware_locals_test.go (1)

46-76: Idempotency test is robust and well‑scoped

This new test cleanly verifies both behavioral idempotency (no further code changes on the second run) and output idempotency (no second “Migrating middleware locals” message). Using full file equality between runs is a strong guard against regressions of the original , true, true bug and similar issues. No further changes needed here.


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.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ReneWerner87 ReneWerner87 merged commit 3e5769d into master Nov 30, 2025
15 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-11-29-15-55-06 branch November 30, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant