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

Json parsing error with content moderation

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

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

@veeceey がすでに取り組んでいます。

2026年2月8日 から。

  • #2847 @danylokv-lang による — マージされずにクローズ
  • #2850 @veeceey による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
api

調査の方向性

client.responses.parse エントリポイントから開始し、issue で説明されている非同期 Azure 設定とレスポンス形式を使用して、Pydantic の検証前にモデレーション拒否がどのように処理されるかを追跡します。動作が再現可能な形で明らかになり、拒否によって生の pydantic_core.ValidationError ではなく、ライブラリが意図する API レスポンスまたはモデレーション関連のエラーが発生すれば完了です。

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

説明

bug
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

Hello,

I've seen an example where I'm submitting to the responses.parse endpoint, and I get back a pydantic validation error. Upon inspection, it looks like the model is returning "I'm sorry, but I cannot assist you with that request.", which obviously fails to json parsing step.

I'd expect it to raise something like a APIResponseValidationError (if not something more specifically related to moderation), instead of a pydantic_core.ValidationError.

To Reproduce

I've found it very difficult to reproduce as the original example is from internal business documents I cannot share, and my attempts to trigger that response have failed.

The basic steps are:

  1. Create client
  2. Submit problematic prompt to client.responses.parse with text_format= pydantic schema
  3. Observe error

For context, I am using the async client, through Microsoft AI Foundry, with chatgpt-4.1-mini, and the content filter is DefaultV2. The Foundry API version is 2025-03-01-preview.

Code snippets
from openai import AsyncAzureOpenAI
credential = DefaultAzureCredential(logging_enable=True)
openai_client = AsyncAzureOpenAI(
        api_version="2025-03-01-preview",
        azure_endpoint=xxx,
        azure_ad_token_provider=get_bearer_token_provider(
            credential,
            "https://cognitiveservices.azure.com/.default",
        ),
)
await openai_client.responses.parse(
    input=prompt,
    text_format=pydantic_schema
)
OS

Windows 11

Python version

Python 3.12.3

Library version

openai 2.15.0

主要言語
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 を短くまとめたダイジェスト。