Skip to content

refactor(sidekick/rust): unify resource name template generation#4538

Closed
haphungw wants to merge 3 commits intogoogleapis:mainfrom
haphungw:feat/unify-resource-name-templates
Closed

refactor(sidekick/rust): unify resource name template generation#4538
haphungw wants to merge 3 commits intogoogleapis:mainfrom
haphungw:feat/unify-resource-name-templates

Conversation

@haphungw
Copy link
Contributor

The Rust generator previously handled explicit fields with ResourceNameFields and heuristic templates with ResourceNameTemplate differently, creating overly complex branch logic. Both explicit resource reference annotations and path-based heuristics are now unified into a single generation source with TargetResource.

This eliminates redundant structs and logic for the codebase, while ensuring that resource names are consistently routed for both heuristic and explicit logic when detailed tracing attributes are enabled.

Fixes #4537

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 refactors resource identification logic, primarily by inverting the priority of heuristic over explicit identification in resource_identification.go. A significant change in internal/sidekick/rust/annotate.go involves the complete removal of the resourceNameCandidateField struct and related functions for identifying and annotating resource name fields within methodAnnotation, along with the ResourceNameFields and HasResourceNameFields fields themselves. While a new HasResourceNameArgs field was added to pathBindingAnnotation for template simplification, a critical issue was introduced: the grpc-client/transport.rs.mustache template now attempts to use the removed Codec.HasResourceNameFields and Codec.ResourceNameFields for detailed tracing attributes, which will lead to code generation failures or incorrect output due to missing data.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.74%. Comparing base (19f0fd4) to head (5a6be0e).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4538   +/-   ##
=======================================
  Coverage   79.74%   79.74%           
=======================================
  Files         109      109           
  Lines        9118     9118           
=======================================
  Hits         7271     7271           
  Misses       1339     1339           
  Partials      508      508           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haphungw haphungw marked this pull request as ready for review March 12, 2026 11:01
@haphungw haphungw requested review from a team as code owners March 12, 2026 11:01
@haphungw haphungw force-pushed the feat/unify-resource-name-templates branch from fdf4839 to cb3f783 Compare March 12, 2026 11:57
@haphungw haphungw requested a review from a team as a code owner March 12, 2026 17:06
@haphungw haphungw force-pushed the feat/unify-resource-name-templates branch from 5588c42 to 5a6be0e Compare March 12, 2026 19:00
@haphungw
Copy link
Contributor Author

already included in #4560

@haphungw haphungw closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sidekick/rust: unify resource name template generation for annotation and heuristic

2 participants