Skip to content

fix: parse design-id label as a UUID string, not raw bytes - #598

Open
singhharsh1708 wants to merge 1 commit into
meshery:masterfrom
singhharsh1708:fix/parse-design-id-uuid
Open

fix: parse design-id label as a UUID string, not raw bytes#598
singhharsh1708 wants to merge 1 commit into
meshery:masterfrom
singhharsh1708:fix/parse-design-id-uuid

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Aug 3, 2026

Copy link
Copy Markdown

What

ParseList reads the design.meshery.io/id label to associate a discovered Kubernetes resource with the Meshery design that created it. It parsed the value with uuid.FromBytes:

id, _ := uuid.FromBytes(value)
result.PatternResource = &id

That label value is the design ID as a canonical UUID string (36 bytes) — the same value is stored as string(value) two lines above. uuid.FromBytes expects exactly 16 raw bytes and returns an error for a 36-byte input; the error is discarded, so id is the zero value and PatternResource (a *uuid.UUID) ends up pointing at the nil UUID 00000000-0000-0000-0000-000000000000 for every design-associated resource. MeshSync therefore never correctly associates a resource with its design.

Fix

Parse the value with uuid.Parse and set PatternResource only when parsing succeeds, so an invalid value leaves it nil rather than a pointer to the nil UUID.

Test

Added TestParseList_DesignIDLabelParsed (table-driven): a valid design-id label sets PatternResource to that UUID; an invalid value leaves it nil. Both cases fail on the current code (they get the nil UUID) and pass with the fix.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of design ID labels when parsing resources.
    • Valid design IDs are now recognized correctly, while invalid values no longer create incorrect resource references.
  • Tests
    • Added coverage for both valid and invalid design ID labels.

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>
@welcome

welcome Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.
Be sure to double-check that you have signed your commits. Here are instructions for making signing an implicit activity while performing a commit.

@github-actions github-actions Bot added the language/go Golang related label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c609787-bf99-487c-8fe2-762478f015a5

📥 Commits

Reviewing files that changed from the base of the PR and between 91420b0 and a7ecf19.

📒 Files selected for processing (2)
  • pkg/model/model_converter.go
  • pkg/model/model_converter_test.go

📝 Walkthrough

Walkthrough

ParseList now parses design ID labels as UUID strings and assigns PatternResource only for valid values. Tests cover valid UUIDs and malformed labels.

Changes

Design ID parsing

Layer / File(s) Summary
Parse and validate design ID labels
pkg/model/model_converter.go, pkg/model/model_converter_test.go
ParseList uses uuid.Parse before assigning PatternResource. Table-driven tests verify valid UUID parsing and nil results for invalid labels.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: leecalcote

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: parsing the design ID label as a UUID string instead of raw bytes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

language/go Golang related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant