You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(llm): AttributeError instead of BadRequestError on list-typed instruction content
_validate_messages in openai.py, anthropic.py, and google.py all check
`(m.content or "").strip()` to detect empty system/developer content.
But `SystemMessage`/`DeveloperMessage.content` is typed
`str | Sequence[TextContent]` -- a plain-dict payload (e.g. content as
a list of `{"type": "text", "text": ...}` blocks, matching real
provider API shapes) validates fine against the Pydantic model, but a
non-empty list is truthy, so `.strip()` is called on a `list` and
raises AttributeError instead of the intended graceful
BadRequestError -- or, for genuinely non-empty content, crashes a
request that should have succeeded.
Fix: use the existing `.text` property (already defined on these
message models for exactly this normalization) instead of raw
`.content`. Same one-line fix duplicated across all three providers.
Added one regression test per provider constructing a developer
message with list-typed content and asserting the completion
succeeds instead of raising AttributeError. TDD red->green verified:
reverting only the three provider files reproduces `AttributeError:
'list' object has no attribute 'strip'` for all three; reapplying
passes. Full libs/giskard-llm unit suite (211 passed, 7 skipped);
ruff/ruff-format clean; basedpyright 0 errors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments