Skip to content

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

Merged
merged 9 commits into from
Nov 20, 2024
Merged

Conversation

ParthSareen
Copy link
Member

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

@ParthSareen ParthSareen requested a review from mxyng November 20, 2024 02:48
@ParthSareen ParthSareen self-assigned this Nov 20, 2024
@ParthSareen ParthSareen removed the request for review from mxyng November 20, 2024 02:48
@jmorganca jmorganca requested a review from mxyng November 20, 2024 03:08
@ParthSareen ParthSareen force-pushed the parth/bugfix/image-encoding branch from 774de0f to 899a7c2 Compare November 20, 2024 19:17
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')
Copy link
Member Author

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

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
Copy link
Member Author

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

@ParthSareen ParthSareen marked this pull request as ready for review November 20, 2024 21:18
@ParthSareen ParthSareen merged commit b0e0409 into parth/tool-parsing Nov 20, 2024
5 checks passed
@ParthSareen ParthSareen deleted the parth/bugfix/image-encoding branch November 20, 2024 23:36
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