Skip to content

fix(models): retry after pydantic schema rebuild error#3106

Open
MukundaKatta wants to merge 1 commit intoopenai:mainfrom
MukundaKatta:codex/openai-python-pydantic-rebuild
Open

fix(models): retry after pydantic schema rebuild error#3106
MukundaKatta wants to merge 1 commit intoopenai:mainfrom
MukundaKatta:codex/openai-python-pydantic-rebuild

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

  • catch PydanticUserError when reading deferred pydantic core schema metadata
  • retry after model_rebuild(force=True, raise_errors=False) before inspecting extras schema
  • add a regression test that exercises the rebuild fallback path with a synthetic model class

Testing

  • python3 -m py_compile src/openai/_models.py tests/test_models.py
  • python3 -m pytest tests/test_models.py -k rebuilds_after_pydantic_user_error (fails locally: ModuleNotFoundError: No module named 'pytest_asyncio')

@MukundaKatta MukundaKatta requested a review from a team as a code owner April 21, 2026 15:02
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0cd49aa3f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openai/_models.py
)

import pydantic
from pydantic.errors import PydanticUserError
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard v2-only PydanticUserError import

Importing PydanticUserError at module load time breaks the declared pydantic>=1.9.0,<3 compatibility path: in Pydantic v1, pydantic.errors does not export PydanticUserError, so importing openai._models raises ImportError before the PYDANTIC_V1 branch can short-circuit. This would fail all v1 environments (including the repo’s test-pydantic-v1 nox session) even though the new retry logic is only intended for v2.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant