Responses API error handling reads error.message, but spec says message is top-level
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.6k
- Forks
- 5.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 96
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
In the Responses API event handling logic, the SDK reads the error message from error.message. However, according to the official documentation, the message field is at the top level of the error object, not nested inside another error field.
if sse.event == "error" and is_mapping(data) and data.get("error"):
message = None
error = data.get("error")
if is_mapping(error):
message = error.get("message")
if not message or not isinstance(message, str):
message = "An error occurred during streaming"
raise APIError(
message=message,
request=self.response.request,
body=data["error"],
)
Official API response example:
{
"type": "error",
"code": "ERR_SOMETHING",
"message": "Something went wrong",
"param": null,
"sequence_number": 1
}
Proposed fix: Change the error handling logic to read data["message"] (the top-level field) and data["error"]["message"] (for backward compatibility) instead of only data["error"]["message"].
To Reproduce
Code snippets
OS
Python version
Library version
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the Responses API event handling logic in src/openai/_streaming.py around line 88, then compare it with the official streaming error response described in the issue. Done means extracting the top-level message while preserving support for the nested error.message form and retaining the existing APIError behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 57/100