fix(bedrock): tolerate null/non-string image_url in Converse content conversion - #55685
Open
MaxFreedomPollard wants to merge 1 commit into
Open
fix(bedrock): tolerate null/non-string image_url in Converse content conversion#55685MaxFreedomPollard wants to merge 1 commit into
MaxFreedomPollard wants to merge 1 commit into
Conversation
Contributor
Author
|
Issue with reproduction: #55686 |
This was referenced Jun 30, 2026
Contributor
|
Thanks for the focused Bedrock regression fix. The premise remains valid on current The proposed Automated hermes-sweeper review. |
MaxFreedomPollard
force-pushed
the
fix/bedrock-null-image-url
branch
2 times, most recently
from
July 31, 2026 03:57
02a5e93 to
3a90ea9
Compare
_convert_content_to_converse read the image url with
image_url.get("url", ""), whose default only applies when the key is
missing. An image_url part whose url is explicitly null (or any
non-string) left url as that value and then called url.startswith(...),
raising AttributeError and aborting conversion of the entire message.
Resolve the url for both the dict ({"url": ...}) and bare-string forms,
then coerce a null/non-string url to an empty string before the data:
check. This mirrors the Gemini and Codex converters, which already
tolerate these shapes, and also lets a bare-string data: url convert to
an image block instead of being dropped.
Adds regression tests for the null url, non-string url, and bare-string
data url cases.
MaxFreedomPollard
force-pushed
the
fix/bedrock-null-image-url
branch
from
July 31, 2026 04:28
3a90ea9 to
9ff5b8b
Compare
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.
Summary
_convert_content_to_converse(agent/bedrock_adapter.py) reads an image part's url with:The
""default only applies when theurlkey is missing. When the key is present but its value isNone(or any non-string),urlbecomes that value andurl.startswith("data:")raisesAttributeError: 'NoneType' object has no attribute 'startswith'. The exception propagates out ofconvert_messages_to_converse, so the whole user message fails to convert and the turn errors out instead of degrading gracefully.Reproduction
Consistency
The sibling converters already tolerate this. Gemini's
_extract_multimodal_partsuses((item.get("image_url") or {}).get("url") or ""), and Codex's_chat_content_to_responses_partsdoesif not isinstance(url, str) or not url: continue. Bedrock is the one converter that crashes.Fix
Resolve the url for both the dict (
{"url": ...}) and bare-string forms, then coerce a null/non-string url to an empty string before thedata:check. As a side benefit, a bare-stringdata:url now converts to an image block instead of being silently dropped (the previouselse ""discarded it).Tests
Adds regression tests for the null-url crash, the non-string-url crash, and bare-string
data:url conversion. The first two fail withAttributeErrorbefore the change and pass after.Fixes #55686