Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix base64 deserialization when using a reader #471

Merged
merged 2 commits into from
Feb 3, 2024
Merged

Fix base64 deserialization when using a reader #471

merged 2 commits into from
Feb 3, 2024

Conversation

ytanay
Copy link
Contributor

@ytanay ytanay commented Feb 3, 2024

In our use case, we deserialize GCP structs using a file reader (instead from an in-memory string), which yields errors such as this:

Caused by:
    invalid type: string "...", expected a borrowed string at line ... column ...

The first commit demonstrates this behavior, and the second fixes it by allowing serde to choose between a borrowed and owned string using a Cow.

Copy link
Owner

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the fix!

I didn't realise that serde can issue runtime errors like that, even though it makes perfect sense that it needs storage in order to deserialize a stream which wasn't taken into consideration. Quite a footgun, I will try to remember that.

@Byron Byron merged commit b74056b into Byron:main Feb 3, 2024
1 of 2 checks passed
@ytanay ytanay deleted the fix-base64-deserialization-borrowed branch February 3, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants