Skip to content

fix(streaming): handle top-level SSE error messages - #3038

Closed
raashish1601 wants to merge 1 commit into
openai:mainfrom
raashish1601:contributor-14/openai-python-2487
Closed

raashish1601 wants to merge 1 commit into
openai:mainfrom
raashish1601:contributor-14/openai-python-2487

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

Summary

  • raise streaming API errors for explicit event: error SSE payloads even when the message is top-level in the JSON object
  • keep the existing nested error.message fallback for backward-compatible streaming payloads
  • add focused sync/async regressions in tests/test_streaming.py

Fixes #2487.

Testing

  • PYTHONPATH=src python -m pytest -o addopts='' tests/test_streaming.py -q
  • PYTHONPATH=src python -m pytest -o addopts='' tests/test_streaming.py -k "error_event_uses_top_level_message or error_event_keeps_nested_error_message_fallback" -q
  • python -m ruff check src/openai/_streaming.py tests/test_streaming.py
  • python -m py_compile src/openai/_streaming.py tests/test_streaming.py
  • git diff --check

Copy link
Copy Markdown
Contributor

Thanks for the fix and tests! We’re consolidating this in #3934, which covers the same streaming-error handling on the current transport code. We’ll keep your error-body checks in scope there. Closing this one to keep review in one place.

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.

Responses API error handling reads error.message, but spec says message is top-level

2 participants