Skip to content

FIX Upload edited images under their own file name in OpenAIImageTarget - #3496

Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/image-edit-upload-filename
Open

Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/image-edit-upload-filename

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Description

Fixes #3494.

OpenAIImageTarget._send_edit_request_async used get_data_filename_async() as the multipart file name for each image. That method generates a new storage path for saving data: a full path under the results directory with a random UUID and a .png extension. So the image's own name was never sent, JPEG and WebP inputs were named .png, and every edit request sent the provider the local results directory, which can include the user's name.

Changes:

  • OpenAIImageTarget uploads each image as Path(image_path).name, which is what OpenAIVideoTarget already does for its image upload.

The bytes and the MIME type are unchanged; they already came from the image itself.

Tests and Documentation

  • New parametrized test in tests/unit/prompt_target/target/test_image_target.py: an edit request with one JPEG, and one with a PNG and a JPEG, sends each image as (file name, bytes, MIME type) with its own file name.
  • On main both cases fail (the generated <uuid>.png path is sent); with this change they pass.
  • pytest tests/unit/prompt_target: 1827 passed, 247 skipped.
  • ruff check, ruff format and ty check pass on the changed files.
  • No documentation changes.

🤖 Generated with Claude Code

The edit request used get_data_filename_async() as the multipart file
name. That generates a new local storage path with a random name and a
.png extension, so the image's real name was never sent, JPEG and WebP
inputs were named .png, and the local results directory was sent to the
provider. Use Path(image_path).name, as OpenAIVideoTarget already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
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.

BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file name

2 participants