-
Notifications
You must be signed in to change notification settings - Fork 702
Bugfix/image encoding #327
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
Conversation
774de0f
to
899a7c2
Compare
if self.value.split('.')[-1] in ('png', 'jpg', 'jpeg', 'webp'): | ||
raise ValueError(f'File {self.value} does not exist') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
img = Image(value='not a path or base64') | ||
assert img.model_dump() == 'not a path or base64' # Should return as-is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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