Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Response.output_text and responses.parse fail when an output_text item has text: null

Đang mở
#3,063 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Bắt đầu với việc tái hiện Response.model_validate(data), Response.output_text và responses.parse(...), sau đó kiểm tra model văn bản đầu ra của response và luồng parsing. Bổ sung coverage hồi quy cho payload có văn bản null được cung cấp và xác minh rằng validation thành công, các mục null bị bỏ qua, còn văn bản không null vẫn được phân tích.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Response.output_text can fail when a Responses API payload includes an output_text content item whose text field is null.

There are two affected layers:

  • strict response parsing rejects ResponseOutputText.text = null
  • parsed responses can still attempt structured parsing on an output_text item whose text is null

Expected behavior:

  • the SDK should accept nullable output_text.text values from the API
  • Response.output_text should ignore null entries instead of failing
  • responses.parse(...) should skip structured parsing for null output_text items

Related PR: #3062

To Reproduce

Create or receive a Responses API payload where a message contains an output_text item with text: null, for example alongside another normal output_text item.

Code snippets
from openai.types.responses.response import Response

data = {
    "id": "resp_null_output_text",
    "object": "response",
    "created_at": 0,
    "status": "completed",
    "background": False,
    "error": None,
    "incomplete_details": None,
    "instructions": None,
    "max_output_tokens": None,
    "max_tool_calls": None,
    "model": "gpt-4o-mini",
    "output": [
        {
            "id": "msg_null_output_text",
            "type": "message",
            "status": "completed",
            "role": "assistant",
            "content": [
                {
                    "type": "output_text",
                    "annotations": [],
                    "logprobs": [],
                    "text": None,
                },
                {
                    "type": "output_text",
                    "annotations": [],
                    "logprobs": [],
                    "text": '{"message":"hello"}',
                },
            ],
        }
    ],
    "parallel_tool_calls": True,
    "previous_response_id": None,
    "prompt_cache_key": None,
    "reasoning": {"effort": None, "summary": None},
    "safety_identifier": None,
    "service_tier": "default",
    "store": True,
    "temperature": 1.0,
    "text": {"format": {"type": "text"}, "verbosity": "medium"},
    "tool_choice": "auto",
    "tools": [],
    "top_logprobs": 0,
    "top_p": 1.0,
    "truncation": "disabled",
    "usage": {
        "input_tokens": 1,
        "input_tokens_details": {"cached_tokens": 0},
        "output_tokens": 1,
        "output_tokens_details": {"reasoning_tokens": 0},
        "total_tokens": 2,
    },
    "user": None,
    "metadata": {},
}

Response.model_validate(data)
OS

Windows 11

Python version

Python 3.13.12

Library version

openai v2.30.0

Ngôn ngữ chính
Python
Star
31.7k
Fork
6.8k
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
128

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/openai-python

Tất cả issue của openai/openai-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.