Skip to content

fix: Linking of v1api compatibility packages - #5720

Open
Bevan Arps (theunrepentantgeek) wants to merge 2 commits into
mainfrom
fix/v1api-package-conversions
Open

Bevan Arps (theunrepentantgeek) wants to merge 2 commits into
mainfrom
fix/v1api-package-conversions

Conversation

@theunrepentantgeek

@theunrepentantgeek Bevan Arps (theunrepentantgeek) commented Sep 22, 2026

Copy link
Copy Markdown
Member

What this PR does

There are two layers of conversion graph used by the code generator.

At the per resource level, we are correctly linking each v1api* version to the new style v* version.

However, those resource level graphs are keyed by type-name; they thus cannot be used when looking up type-renames.

The resource level graphs for oldname and newname will be wholly disjoint, with no link.

We therefore also have a group level conversion graph used to navigate renames, identifying the transition points between the lower level.

We have been incorrectly constructing this higher level graph. The implementation of compatibilityReferencesConvertToOriginalPackage() formerly assumed an interleaving sort order for package versions:

v1api20210101preview
v20210101preview
v1api20211101
v20211101
v1api20221001preview
v20221001preview
v1api20240101
v20240101

However, the actual sorting order has all old-style packages preceding all new-style packages:

v1api20210101preview
v1api20211101
v1api20221001preview
v1api20240101
v20210101preview
v20211101
v20221001preview
v20240101

This resulted in the graph being constructed incorrectly and broke the type-lookup search associated with renaming.

To fix this, compatibilityReferencesConvertToOriginalPackage() is now order agnostic, creating the necessary links regardless of sorting order.

How does this PR make you feel?

gif

Checklist

  • this PR contains tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The unresolved lint failure and compatibility traversal issue must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR fixes generator conversion-graph linking between legacy v1api and new-style v packages regardless of sort order.

Changes:

  • Makes compatibility linking order-independent.
  • Adds regression coverage for hybrid preview renames.
  • Addresses remaining critical lint and moderate traversal issues before approval.
File Summary
v2/​tools/​generator/​internal/​codegen/​storage/​group_conversion_graph_builder.go Updates compatibility linking; unresolved critical lint issue (3 votes) and moderate traversal issue (1 vote).
v2/​tools/​generator/​internal/​codegen/​storage/​conversion_graph_test.go Adds regression coverage for hybrid rename behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +120 to 123
original, ok := asNewStylePackageReference(ref)
if !ok {
continue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants