Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc1e0ef706
ℹ️ 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 bytes = BASE64_STANDARD | ||
| .decode(payload) | ||
| .map_err(|_| PromptImageUrlError::InvalidBase64Payload)?; | ||
| if bytes.is_empty() { | ||
| return Err(PromptImageUrlError::EmptyBase64Payload); | ||
| } | ||
| image::load_from_memory(&bytes).map_err(|_| PromptImageUrlError::InvalidImageBytes)?; |
There was a problem hiding this comment.
Bound inline image validation before decoding
When a v2/app-server caller or MCP/dynamic tool supplies a large inline data: image URL, this validator decodes the entire base64 payload and then asks image to parse it without any size cap; the app-server text limit only counts text input, so a single image field can force large allocations/CPU before the input is rejected or forwarded. Please cap the accepted payload size before decoding/parsing, or reuse an existing bounded image-loading path.
Useful? React with 👍 / 👎.
b1661f2 to
536a439
Compare
283efa3 to
aaf4fcd
Compare
aaf4fcd to
ef5acb2
Compare
Why
Fixes #16605.
A malformed image payload can be persisted into model-visible history and then replayed on later turns or after resume. When the Responses API rejects that replay with an
invalid_value.image_urlerror, the thread can stay poisoned because the same bad payload is reconstructed and sent again.This PR keeps the fix focused on recognizing those API errors and recovering the thread by rolling back the failed turn. Inline image preflight validation in app-server, protocol conversion, or dynamic tool output paths is intentionally left for a follow-up.
What changed
CodexErr::InvalidImageRequest(), including.image_urlinvalid_valueresponses and the empty-base64 image message.ThreadRolledBackevent plus a user-facing error when automatic rollback succeeds or fails.Invalid image; rollback is now the recovery behavior.Local testing
Before:

After:

Quitting and resuming thread:

Verification
cargo fmt --all --check --manifest-path codex-rs/Cargo.tomlcargo test -p codex-api --lib map_api_error_maps_invalid_image --manifest-path codex-rs/Cargo.tomlcargo test -p codex-api --lib map_api_error_maps_empty_base64_image_message_from_400_body --manifest-path codex-rs/Cargo.tomlcargo test -p codex-core --lib context_manager::history::tests --manifest-path codex-rs/Cargo.tomlcargo test -p codex-core --lib session::tests::thread_rollback --manifest-path codex-rs/Cargo.toml