Bugfix/image encoding - #327
Merged
Merged
Conversation
ParthSareen
force-pushed
the
parth/bugfix/image-encoding
branch
from
November 20, 2024 19:17
774de0f to
899a7c2
Compare
ParthSareen
commented
Nov 20, 2024
ParthSareen
commented
Nov 20, 2024
Comment on lines
+101
to
+102
| if self.value.split('.')[-1] in ('png', 'jpg', 'jpeg', 'webp'): | ||
| raise ValueError(f'File {self.value} does not exist') |
Member
Author
There was a problem hiding this comment.
This is to handle the edge case where a path does not exist but could be a valid b64 string - would lead to weird behavior
ParthSareen
commented
Nov 20, 2024
Comment on lines
+23
to
+24
| img = Image(value='not a path or base64') | ||
| assert img.model_dump() == 'not a path or base64' # Should return as-is |
Member
Author
There was a problem hiding this comment.
Currently just a passthrough. Since spaces are valid b64 I'm hesitant to split on it and check the length. although we could do a heuristic to catch it greedily
ParthSareen
marked this pull request as ready for review
November 20, 2024 21:18
mxyng
approved these changes
Nov 20, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Images are not being encoded correctly given a b64 string - it tries to encode it twice.
Updated the types for Image as well as the serialization to better handle these cases - added tests as well