Skip to content

fix: coerce model to str() — prevent crash on non-string model kwargs#256

Merged
bmdhodl merged 2 commits intomainfrom
fix/sdk-model-str-coerce
Mar 15, 2026
Merged

fix: coerce model to str() — prevent crash on non-string model kwargs#256
bmdhodl merged 2 commits intomainfrom
fix/sdk-model-str-coerce

Conversation

@bmdhodl
Copy link
Owner

@bmdhodl bmdhodl commented Mar 15, 2026

Follow-up to PR #255. Codex flagged that storing model directly in span data without sanitization could crash json.dumps if the model kwarg is a non-JSON-serializable object (enum, wrapper type). This would abort the LLM call before original_create runs — breaking the user's code.

Fix: str(kwargs.get("model", "unknown")) in all 4 patch variants (sync/async x openai/anthropic).

🤖 Generated with Claude Code

Codex review: if model kwarg is a non-JSON-serializable object
(enum, wrapper type), json.dumps in the sink would crash BEFORE
the LLM call runs — breaking the user's code. Previously model
was only interpolated into the span name (implicit str), so this
regression was introduced by adding data={"model": model}.

Fix: str(kwargs.get("model", "unknown")) in all 4 patch variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@bmdhodl bmdhodl merged commit 13d3afd into main Mar 15, 2026
10 checks passed
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.

1 participant