Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Update comment and decode bytes instead#63754

Merged
pjlast merged 4 commits into
mainfrom
pjlast/441-follow-up
Jul 11, 2024
Merged

Update comment and decode bytes instead#63754
pjlast merged 4 commits into
mainfrom
pjlast/441-follow-up

Conversation

@pjlast

@pjlast pjlast commented Jul 10, 2024

Copy link
Copy Markdown
Contributor

Minor adjustment to decode the base64 encoded JSON directly to bytes instead of a string, and update the associated coment.

Test plan

Existing test should still pass

Changelog

@cla-bot cla-bot Bot added the cla-signed label Jul 10, 2024
@pjlast pjlast requested a review from eseliger July 10, 2024 15:44
@github-actions github-actions Bot added team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all labels Jul 10, 2024
@pjlast pjlast enabled auto-merge (squash) July 10, 2024 15:44
Comment on lines +165 to +171
var protectsJson []byte
_, err := base64.StdEncoding.Decode(protectsJson, parsedBrokerResponse.Data)
if err != nil {
return nil, errors.Wrap(err, "failed to unescape protects response")
}

return parseP4Protects([]byte(protectsJson))
return parseP4Protects(protectsJson)

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.

I think this could be return parseP4Protects(parsedBrokerResponse.Data)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No it still needs to be decoded?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

parsedBrokerResponse.Data is still base64 encoded

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.

My understanding is that []byte is always assuming base64 content when unmarshalling already and decoding that correctly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That doesn't sound right to me 😅 . Perhaps when you encode a []byte ? But decoding JSON to []byte definitely shouldn't do that

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.

that is how they encode []byte into JSON because it's not guaranteed to be UTF8 :D

@pjlast pjlast disabled auto-merge July 10, 2024 16:00
@pjlast pjlast merged commit 1e8a1bb into main Jul 11, 2024
@pjlast pjlast deleted the pjlast/441-follow-up branch July 11, 2024 07:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants