fix(generate_image): use requested output_format for saved filename extension#501
Open
kimnamu wants to merge 1 commit into
Open
Conversation
…xtension The saved file extension was hardcoded to .png while the output_format (default "jpeg") is threaded through both the Bedrock request and the ToolResult image format. A default run therefore wrote JPEG bytes into a .png file and reported a .png path that disagreed with the returned "format": "jpeg". Derive the extension from output_format so the on-disk filename matches the requested/returned format. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks to the maintainers for this tool. Small, low-risk fix.
Fixes #500
Problem
generate_imagethreadsoutput_format(default"jpeg") into the Bedrock request and the returned ToolResultformat, but the saved filename is hardcoded.png. A default run writes JPEG bytes into a.pngfile and reports a.pngpath that disagrees with"format": "jpeg".Fix
Derive the saved extension from the existing
output_formatvariable — filling the one place an already-established pattern was missing. No new helper, no behavior change beyond the correct extension.Before / After
output_format="jpeg") saved fileoutput/a_cute_robot.pngoutput/a_cute_robot.jpegformatjpegjpeg(unchanged).pngvsjpeg)output_format="png"run.png.png(unchanged)Tests
Added 2 cases to
tests/test_generate_image.py(reusing existing mocks). Reverting the source makes the jpeg case fail (file saved as.png); restoring makes all 7 pass.ruff format/ruff checkclean on changed files.This contribution was prepared with the help of an AI agent (Claude Code); I reviewed every line, the rationale, and the test results before submitting.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.