🐛 Bug Report: OpenAI Responses: with_raw_response.create() raises when the body can't be parsed, though the uninstrumented call returns
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
v1/responses_wrappers.pyで、674行目と867行目付近にある同期および非同期のparse_response呼び出しから始め、その後、TracedDataの作成に失敗した場合に使われる既存のwrapperのfallbackを調べてください。issueのモックHTTPトランスポートを使って、両方の経路をカバーするテストを追加してください。完了条件は、不正なJSONで例外を発生させたりメトリクスを記録したりせず、生のレスポンスを返すことです。
索引モデルが issue の本文から書いたものです。
説明
Which component is this bug for?
OpenAI Instrumentation
📜 Description
client.responses.with_raw_response.create() is meant to return the raw HTTP response without parsing the body. The user decides whether to call .parse().
The Responses wrapper in v1/responses_wrappers.py calls parse_response(response) itself, so it can read the response ID, model and usage. That call sits outside the wrapper's try/except (around line 674 for sync and line 867 for async). If the body can't be parsed, the exception from our .parse() goes up to the user. The same call returns normally when the instrumentation is off.
The async path (async_parse_response) has the same problem.
👟 Reproduction steps
import httpx, openai
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
def bad(req):
return httpx.Response(200, headers={"content-type": "application/json"}, content=b"{not json")
def call():
c = openai.OpenAI(api_key="k", max_retries=0,
http_client=httpx.Client(transport=httpx.MockTransport(bad)))
return c.responses.with_raw_response.create(model="m", input="hi")
print(type(call()).__name__) # LegacyAPIResponse
OpenAIInstrumentor().instrument()
call() # raises JSONDecodeError
👍 Expected behavior
The instrumentation never changes what the call returns or raises. If it can't parse the raw response, it should return the response untraced and record no metrics. The wrapper already does this when building TracedData fails (except Exception: return response).
👎 Actual Behavior with Screenshots
uninstrumented: returned LegacyAPIResponse status 200
instrumented: raised JSONDecodeError
📃 Provide any additional context for the Bug.
- This has been there since the first Responses instrumentation (#3052).
- CodeRabbit raised it on #4713. It suggested recording duration and
error.typeand then re-raising. That would still break the user's call, and it would count a successful API call as a failed operation. So the fix is to guard the parse, not to record it as an error. - Suggested fix: wrap
parse_response/async_parse_responseintry/except Exception: return responsein both the sync and async wrappers. Add a test using the mock transport above that checks the instrumented call returns the same object as the uninstrumented one. - Related: #4504, #4551, #4476 (other
with_raw_responseissues in the Responses wrapper).
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
- 主要言語
- Python
- スター
- 7.5k
- フォーク
- 1.2k
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
traceloop/openllmetry のほかの issue
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentation対応中かも @Quantum-Enigma-dot が 21 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
traceloop/openllmetry#4665 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completions対応中かも @jayfeng7 が 23 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
traceloop/openllmetry#4660 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bug Report: Failed dataset deletes still remove local rows and columns対応中かも @inchang-ing が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
traceloop/openllmetry#4630 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penalty対応中かも @shantam77 が 38 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
traceloop/openllmetry#4598 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: LiteLLM instrumentation never ends the span when a call is interrupted (KeyboardInterrupt, asyncio cancellation)対応中かも @rupak-eng が 39 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
traceloop/openllmetry#4597 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
traceloop/openllmetry の issue をすべて見る
似ている issue
-
Internal Errorオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
frappe/frappe_docker#2071 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
The-Pocket/PocketFlow#161 ·
-
comp/desktop P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#157702 ·
メンテナーはふだん 1 日以内に返信
-
scibench_physics / scibench_chemistry: a correct answer scores 0 when the unit has a power of ten対応中かも @BahaaMattar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
EvolvingLMMs-Lab/lmms-eval#1699 ·
メンテナーはふだん 1 日以内に返信
-
project_inputs.html uses undefined file variable for dropdown IDs, lacks visual tag badges, and has empty delete labels対応中かも @Rucha0901 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aboutcode-org/scancode.io#2354 ·
メンテナーはふだん 1 日以内に返信