This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Update comment and decode bytes instead#63754
Merged
Merged
Conversation
eseliger
reviewed
Jul 10, 2024
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) |
Member
There was a problem hiding this comment.
I think this could be return parseP4Protects(parsedBrokerResponse.Data)
Contributor
Author
There was a problem hiding this comment.
No it still needs to be decoded?
Contributor
Author
There was a problem hiding this comment.
parsedBrokerResponse.Data is still base64 encoded
Member
There was a problem hiding this comment.
My understanding is that []byte is always assuming base64 content when unmarshalling already and decoding that correctly
Contributor
Author
There was a problem hiding this comment.
That doesn't sound right to me 😅 . Perhaps when you encode a []byte ? But decoding JSON to []byte definitely shouldn't do that
Member
There was a problem hiding this comment.
that is how they encode []byte into JSON because it's not guaranteed to be UTF8 :D
eseliger
approved these changes
Jul 10, 2024
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.
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