This repository was archived by the owner on Aug 5, 2026. It is now read-only.
fix(archive): kind cross-check on definition-ref label resolution - #25
Merged
Conversation
Step 1 of searchCompositionDefinition trusted the definition-ref labels blindly: if they ever pointed at a CompositionDefinition of a different kind (mislabeled instance, name reuse after delete/recreate) it would fetch the wrong chart. Verify status.kind against the instance kind via getChartVersionKind before using the referenced definition; on mismatch (or unreadable status kind) log a Warn and fall through to the exact version+kind match instead of using it or erroring. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Hardening follow-up to #24. Step 1 of
searchCompositionDefinition(definition-ref label resolution) trusted the instance'scomposition-definition-name/-namespacelabels blindly — no kind cross-check. If those labels ever pointed at a CompositionDefinition of a different kind (mislabeled instance, or name reuse after a delete/recreate), step 1 would resolve — and fetch — the wrong chart.The guard
After finding the CD by name+namespace in step 1, verify its
status.kindequals the instance kind (via the existinggetChartVersionKindhelper; its version return is ignored, and an error reading the status kind is treated as a mismatch):Warn(refName/refNamespace, expected kind, found kind) and fall through to step 2 (exact version+kind match) — the mislabeled CD is neither used nor turned into an error, so the later fallbacks can still resolve the true owner.The stale-label path (ref labels matching no CD at all) keeps its existing Debug log and fall-through.
Test
New table case in
getter_search_test.go: instance ref-labels point at an existing CD whosestatus.kinddiffers → resolution falls through and succeeds via the exact version+kind match on the true owner. All 7 cases pass:gofmtclean,go build ./...andgo test ./internal/tools/archive/...pass.🤖 Generated with Claude Code