-
Notifications
You must be signed in to change notification settings - Fork 55
Fix OpenAI input image sanitization #384
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 OpenAI input image sanitization #384
Conversation
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.
Additional Comments (1)
-
posthog/ai/sanitization.py, line 99-102 (link)style: inconsistent type checking -
sanitize_openai_imagechecksisinstance(item.get("image_url"), str)but this function only checks"image_url" in item
2 files reviewed, 1 comment
|
@ablaszkiewicz Sorry for tagging you but any chance to review this? |
|
lgtm ✅ Python pipeline is currently broken. We are fixing it |
|
@ablaszkiewicz hey , any update on this |
|
@vikas5914 can you please recreate this PR as a new one? You can tag me there |
|
@vikas5914 nevermind. It went through |
|
@vikas5914 Ooops there was no |
Summary
Extend
sanitize_openai_imageto redact base64 data when OpenAI’s Responses API sends input_image items where image_url is a string (as documented here).Restore the regression test for that payload format so we cover both dict-style image_url objects and string URLs.
The previous check only handled { "type": "image_url", "image_url": { "url": ... } }. But OpenAI also allows:
Example from the official docs:
Without this fix, base64 strings in that shape weren’t redacted.