-
Notifications
You must be signed in to change notification settings - Fork 6.1k
verify mime type of images #5888
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
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.
Let's add an integration test
|
|
||
| let output_item = mock.single_request().function_call_output(call_id); | ||
| let output_text = extract_output_text(&output_item).expect("output text present"); | ||
| assert_eq!(output_text, "attached local image path"); |
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.
that's actually not very good. It might be better to respond with error directly as function output instead of separate item but you are not the one that wrote the logic.
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.
@codex could you take a stab at this
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let output_item = mock.single_request().function_call_output(call_id); | ||
| let output_text = extract_output_text(&output_item).expect("output text present"); | ||
| assert_eq!(output_text, "attached local image path"); |
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.
Surface MIME rejection as tool failure
Here we now assert that function_call_output is still "attached local image path" even when the local file was rejected for having a non‑image MIME type. That keeps the view_image handler returning success: true and the usual success string, even though the pending input we send back no longer contains any input_image. The only hint is the placeholder text we injected as a user message, which isn’t structurally tied to the tool call and can be ignored by downstream consumers. All of the other failure paths for this tool (missing file, path is directory, etc.) surface their errors via FunctionCallError::RespondToModel, so orchestration, telemetry, and the model can reliably tell the call failed. With this change MIME failures become silent: the agent continues as if the screenshot is attached while the Responses API request contains no image. We should instead propagate the MIME error through the tool’s function output (success: Some(false) plus the error message) so callers can react, rather than asserting success here.
Useful? React with 👍 / 👎.
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.
strange. why did my ping get classified as a review request lol
solves: #5675
Block non-image uploads in the view_image workflow. We now confirm the file’s MIME is image/* before building the data URL; otherwise we emit a “unsupported MIME type” error to the model. This stops the agent from sending application/json blobs that the Responses API rejects with 400s.