Skip to content

claircore: add JSON marshaling for Alias type#1896

Merged
jvdm merged 2 commits into
quay:mainfrom
jvdm:fix-alias-json
Jun 23, 2026
Merged

claircore: add JSON marshaling for Alias type#1896
jvdm merged 2 commits into
quay:mainfrom
jvdm:fix-alias-json

Conversation

@jvdm

@jvdm jvdm commented May 27, 2026

Copy link
Copy Markdown
Contributor

unique.Handle[string] does not implement json.Marshaler, causing Alias.Space to serialize as {} instead of the actual namespace value. This breaks vulnerability bundle serialization via jsonblob.

Add MarshalJSON and UnmarshalJSON to preserve Space values through JSON round-trips.

@jvdm jvdm requested a review from a team as a code owner May 27, 2026 23:24
@jvdm jvdm requested review from hdonnay and removed request for a team May 27, 2026 23:24
@jvdm jvdm force-pushed the fix-alias-json branch 2 times, most recently from 524d0ad to ff47f30 Compare May 28, 2026 01:38
Comment thread alias.go Outdated
}

type aliasJSON struct {
Space string `json:"Space"`

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.

Do we want the JSON keys to be capitalized? Seems like everything else is lower

Comment thread alias_test.go
}
want := `{"Space":"","Name":""}`
if got := string(data); got != want {
t.Errorf("marshal: got %s, want %s", got, want)

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.

It seems like this isn't going to be totally symmetrical, i.e unmarshaling {"Space":"","Name":""} will return something different from Alias{} should. Do you think it's worth calling unmarshal and checking Valid() is false?

@jvdm jvdm force-pushed the fix-alias-json branch from ff47f30 to 1e48ce3 Compare May 28, 2026 19:18
@crozzy

crozzy commented May 28, 2026

Copy link
Copy Markdown
Contributor

blocked by #1891

@jvdm jvdm force-pushed the fix-alias-json branch 2 times, most recently from c942d87 to 4629529 Compare June 4, 2026 23:40
@jvdm jvdm force-pushed the fix-alias-json branch from 4629529 to 954242a Compare June 17, 2026 22:19
@crozzy crozzy self-requested a review June 23, 2026 16:47
@jvdm jvdm force-pushed the fix-alias-json branch from 954242a to e28c196 Compare June 23, 2026 19:42

@hdonnay hdonnay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the outstanding deadlock isn't a concern, this should be fine.

I think we can live with the JSON marshaling continuing to be load bearing until a v2 or new updater subsystem.

jvdm added 2 commits June 23, 2026 17:15
unique.Handle[string] does not implement json.Marshaler, causing
Alias.Space to serialize as {} instead of the actual namespace value.

Add MarshalJSON and UnmarshalJSON to preserve Space values through JSON
round-trips.

Signed-off-by: J. Victor Martins <jvdm@sdf.org>
…bilities

Signed-off-by: J. Victor Martins <jvdm@sdf.org>
@jvdm jvdm force-pushed the fix-alias-json branch from e28c196 to 153dcb3 Compare June 23, 2026 20:19
@jvdm jvdm requested a review from a team as a code owner June 23, 2026 20:19
@jvdm jvdm requested review from BradLugo and removed request for BradLugo June 23, 2026 20:19
@jvdm jvdm merged commit e6cd4c8 into quay:main Jun 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants