Skip to content

fix(bedrock): guard against null url in image_url parts and lifecycle status (#55686) - #92

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-55996
Open

fix(bedrock): guard against null url in image_url parts and lifecycle status (#55686)#92
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-55996

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

Prevent AttributeError crash when Bedrock Converse encounters an image_url part with a null url field, or a model lifecycle entry with a null status.

Problem

Two .get(key, "") patterns crash when the key exists with value None:

  1. image_url.get("url", "") returns None (not "") when url is explicitly null → url.startswith("data:") raises AttributeError: 'NoneType' object has no attribute 'startswith'

  2. lifecycle.get("status", "").upper() returns None when status is null → .upper() raises AttributeError

The dict.get(key, default) default only applies when the key is absent, not when it is present with value None.

Fix

Use (x.get("key") or "") which coalesces both absent-key and None-value to empty string:

  • image_url.get("url") or "" — null URL parts are safely skipped (empty string doesn't match data: prefix)
  • lifecycle.get("status") or "" — null status is treated as non-ACTIVE (model skipped)

Fixes NousResearch#55686


Mirror-of: NousResearch#55996
NousResearch#55996

@tenki-reviewer

tenki-reviewer Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Complete
No issues found!

Risk: 🟢 Low (12/100) — no findings · 4 LOC across 1 file


This PR patches two sites in agent/bedrock_adapter.py where dict.get(key, default) can propagate None instead of the default when the Bedrock API returns a key with a null value. A third instance of the same pattern was identified in the same function but fell below the confidence threshold.

Files Reviewed (1 files)
agent/bedrock_adapter.py

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.

Bedrock Converse conversion crashes (AttributeError) on an image_url part with a null url

1 participant