Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#2,487 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@LuminaX-alt がすでに取り組んでいます。

2025年7月31日 から。

  • #6 @LuminaX-alt による — オープン
  • #3038 @raashish1601 による — マージされずにクローズ
  • #3587 @mayuriphad による — マージされずにクローズ
  • #3934 @KaiyiQuan による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
api

調査の方向性

src/openai/_streaming.py の 88 行目付近にある Responses API のイベント処理ロジックを読み、その後、issue に記載されている公式のストリーミングエラーレスポンスと比較します。トップレベルのメッセージを抽出し、ネストされた error.message 形式のサポートを維持し、既存の APIError の動作を保持できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug sdk
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.

SDK code (current behavior):

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
主要言語
Python
スター
31.8k
フォーク
8k
平均マージ
1日 1時間
マージ済み PR(30日)
137

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openai/openai-python のほかの issue

openai/openai-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。