fix: parse design-id label as a UUID string, not raw bytes - #598
fix: parse design-id label as a UUID string, not raw bytes#598singhharsh1708 wants to merge 1 commit into
Conversation
ParseList read the design.meshery.io/id label with uuid.FromBytes, but the label value is the design ID as a canonical UUID string (36 bytes), not 16 raw bytes. FromBytes returned an error which was discarded, so PatternResource was set to a pointer to the nil UUID for every design-associated resource, and MeshSync never associated a discovered resource with the design that created it. Parse the value with uuid.Parse and only set PatternResource on success, so an invalid value leaves it nil instead of the nil UUID. Signed-off-by: Harsh Singh <hs1663531@gmail.com>
|
Yay, your first pull request! 👍 A contributor will be by to give feedback soon. In the meantime, you can find updates in the #github-notifications channel in the community Slack. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesDesign ID parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
What
ParseListreads thedesign.meshery.io/idlabel to associate a discovered Kubernetes resource with the Meshery design that created it. It parsed the value withuuid.FromBytes:That label value is the design ID as a canonical UUID string (36 bytes) — the same
valueis stored asstring(value)two lines above.uuid.FromBytesexpects exactly 16 raw bytes and returns an error for a 36-byte input; the error is discarded, soidis the zero value andPatternResource(a*uuid.UUID) ends up pointing at the nil UUID00000000-0000-0000-0000-000000000000for every design-associated resource. MeshSync therefore never correctly associates a resource with its design.Fix
Parse the value with
uuid.Parseand setPatternResourceonly when parsing succeeds, so an invalid value leaves itnilrather than a pointer to the nil UUID.Test
Added
TestParseList_DesignIDLabelParsed(table-driven): a valid design-id label setsPatternResourceto that UUID; an invalid value leaves itnil. Both cases fail on the current code (they get the nil UUID) and pass with the fix.Summary by CodeRabbit