Skip to content

feat(migrator): implement migration for params tag keys to use uri format#273

Merged
ReneWerner87 merged 1 commit intomasterfrom
migrator_params_tag
Feb 18, 2026
Merged

feat(migrator): implement migration for params tag keys to use uri format#273
ReneWerner87 merged 1 commit intomasterfrom
migrator_params_tag

Conversation

@ReneWerner87
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 18, 2026 15:05
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner February 18, 2026 15:05
@ReneWerner87 ReneWerner87 requested review from efectn, gaby and sixcolors and removed request for a team February 18, 2026 15:05
@ReneWerner87 ReneWerner87 added the ✏️ Feature New feature or request label Feb 18, 2026
@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 a significant migration to update struct tags from params to uri format, aligning with evolving parsing standards. Concurrently, it modernizes various parts of the codebase by adopting newer Go standard library features for slice and map operations, and string handling. These changes enhance code maintainability, consistency, and prepare the project for future updates.

Highlights

  • New Migration for Params Tag Keys: Implemented a new migration, MigrateParamsTagKeys, which automatically converts params:"key" struct tags to uri:"key" across the codebase. This ensures compatibility with updated URI parsing conventions.
  • Code Modernization and Refactoring: Several files were updated to leverage modern Go features, including the slices and maps packages, and strings.CutPrefix and strings.SplitSeq functions. This improves code readability and efficiency by replacing manual iteration loops and string manipulation with standard library functions.
  • Makefile Update: A new modernize target has been added to the Makefile, allowing developers to easily run gopls modernize to apply automatic code improvements.
  • Improved Test Coverage: New test cases were added for the params tag key migration, and an existing test was updated to confirm that the MigrateParserMethods migration does not inadvertently alter params tags.
Changelog
  • Makefile
    • Added a new modernize target to run gopls modernize.
  • cmd/dev.go
    • Imported the slices package.
    • Replaced manual iteration loops with slices.Contains for checking extensions, ignored directories, and ignored files.
  • cmd/internal/migrations/lists.go
    • Added v3migrations.MigrateParamsTagKeys to the list of v3 migrations.
  • cmd/internal/migrations/v3/cache_config.go
    • Replaced strings.HasPrefix and strings.TrimPrefix with strings.CutPrefix for cleaner string manipulation.
  • cmd/internal/migrations/v3/client_usage.go
    • Imported the maps package.
    • Replaced manual map copying with maps.Copy.
    • Used the max function for boundary calculation.
    • Replaced strings.Split with strings.SplitSeq for iterating over query parameters.
  • cmd/internal/migrations/v3/params_tag_keys.go
    • Added a new file implementing the MigrateParamsTagKeys function to convert params:"key" struct tags to uri:"key".
  • cmd/internal/migrations/v3/params_tag_keys_test.go
    • Added a new test file with various test cases for the MigrateParamsTagKeys function, covering different scenarios of tag rewriting.
  • cmd/internal/migrations/v3/parser_methods_test.go
    • Added a new test case Test_MigrateParserMethods_DoesNotRewriteParamsTagToURI to ensure MigrateParserMethods does not modify params tags.
  • cmd/internal/migrations/v3/session_release.go
    • Replaced strings.Split with strings.SplitSeq for iterating over lines.
    • Used max and min functions for boundary calculations in hasExistingRelease.
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 introduces a new migration to update params struct tags to uri format, aligning with recent changes in the framework. The implementation correctly uses go/ast and go/parser to modify the tags, and comprehensive test cases are provided to ensure its correctness across various scenarios. Additionally, several existing files have been modernized by adopting newer Go standard library functions such as slices.Contains, maps.Copy, strings.CutPrefix, and strings.SplitSeq. These changes enhance code readability, conciseness, and efficiency. Overall, the changes are well-implemented and contribute positively to the codebase's maintainability and adherence to modern Go practices.

@ReneWerner87 ReneWerner87 merged commit b446401 into master Feb 18, 2026
19 checks passed
@ReneWerner87 ReneWerner87 deleted the migrator_params_tag branch February 18, 2026 15:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new v3 migration step to rewrite struct tag keys from params to uri (URI-format tags), integrating it into the migration pipeline and expanding test coverage. Also includes several small Go “modernize” refactors across existing migrations/dev tooling.

Changes:

  • Add MigrateParamsTagKeys migration to rewrite params:"..." struct tags to uri:"...".
  • Register the new migration in the v3 migration list and add dedicated tests (plus a parser-methods regression test).
  • Modernize a few areas using newer stdlib helpers (maps.Copy, slices.Contains, strings.SplitSeq, min/max, strings.CutPrefix) and add a Makefile target for running modernize.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/internal/migrations/v3/params_tag_keys.go Implements struct-tag rewrite migration (paramsuri).
cmd/internal/migrations/v3/params_tag_keys_test.go Adds tests covering rewrite behavior and no-op case.
cmd/internal/migrations/v3/parser_methods_test.go Adds regression test ensuring parser-method migration doesn’t rewrite tags.
cmd/internal/migrations/lists.go Registers the new migration in the v3 migration sequence.
cmd/internal/migrations/v3/session_release.go Minor refactor using SplitSeq and min/max.
cmd/internal/migrations/v3/client_usage.go Minor refactor using maps.Copy and SplitSeq.
cmd/internal/migrations/v3/cache_config.go Minor refactor using strings.CutPrefix.
cmd/dev.go Minor refactor using slices.Contains.
Makefile Adds modernize target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +46 to +56
tagLiteral, err := strconv.Unquote(field.Tag.Value)
if err != nil || !strings.Contains(tagLiteral, `params:"`) {
return true
}

updatedTag := strings.ReplaceAll(tagLiteral, `params:"`, `uri:"`)
if updatedTag == tagLiteral {
return true
}

field.Tag.Value = "`" + updatedTag + "`"
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

rewriteParamsTagKeys does a plain strings.ReplaceAll on params:", which will also rewrite tag keys that merely contain "params" (e.g. xparams:"id" would become xuri:"id"). Consider using a stricter match (e.g. regexp with a word boundary or start/space delimiter) so only the exact params key is renamed.

Also, this always re-emits the tag as a raw backquoted literal (...), which changes the literal form if the original tag used a quoted string and can produce invalid Go if the tag content contains a backquote. Preserving the original quoting style (or using strconv.Quote when needed) would avoid that edge case.

Copilot uses AI. Check for mistakes.
## modernize: 🛠 Run gopls modernize
.PHONY: modernize
modernize:
GOTOOLCHAIN=$(GOVERSION) go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test=false ./...
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The modernize target sets GOTOOLCHAIN=$(GOVERSION), but GOVERSION isn’t defined anywhere in this Makefile. This will typically expand to an empty value and won’t select the intended toolchain; use $(TOOLCHAIN) here or define GOVERSION consistently.

Suggested change
GOTOOLCHAIN=$(GOVERSION) go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test=false ./...
GOTOOLCHAIN=$(TOOLCHAIN) go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test=false ./...

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✏️ Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants