Repository navigation
fix: preserve declared aliases during Pydantic v1 validation - #4119
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Castiron custom codeEvaluated main: Trusted main policy: ✅ No new custom-code files detected. 39 mixed files remain; 0 existing customizations changed. Compared 39 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 39338454215 --repo openai/openai-python \
--name castiron-custom-code-39338454215-1 --dir /tmp/castiron-custom-code-39338454215-1
git apply --stat /tmp/castiron-custom-code-39338454215-1/custom-code.patch
cat /tmp/castiron-custom-code-39338454215-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 90c0bacc07ddd5662598db52b3c3011973011973 912bc698beae3126892cff0009d62804187fd237
python3 scripts/castiron/custom_code_report.py report \
--base 90c0bacc07ddd5662598db52b3c3011973011973 \
--head 912bc698beae3126892cff0009d62804187fd237 --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-912bc698beae
cat /tmp/castiron-custom-code-912bc698beae/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Approved at 912bc69. Two static reviews found no actionable issues across the complete three-file diff and relevant Pydantic v1 validation, nested/generic model, and Responses parsing paths. The pre-validator preserves declared wire aliases, retains keys consumed by other declared aliases, and avoids mutating caller input. Pydantic v2 and loose construction are unchanged.
Hosted checks are successful/skipped, and the exact-head OkTest report records 236/236 passed. No candidate code or tests were executed for this review.
With Pydantic v1, a valid Responses function call containing both
"async": trueand an extra"async_": "future"can replace the validated boolean with that extra value. The same problem affects nested validated SDK models with other aliased fields.Preserve the declared wire field during Pydantic v1 validation and discard only the colliding extra. Keep unrelated extra fields, input dictionaries, and keys used as another declared wire alias intact. Pydantic v2 and loose construction keep their existing behavior.
Tests cover public synchronous and asynchronous Responses parsing, valid and future union variants, generic models, and overlapping declared aliases. On Python 3.10, the focused model tests pass on the minimum supported Pydantic 1.10.13 and on 1.10.26 (66 passed, 13 existing v2-only skips); Pydantic 2.12.5 passes all 79. Broader model and WebSocket suites pass with v1 (1,634 passed, 13 skipped) and v2 (1,647 passed). Ruff, Pyright, mypy, and the exact-commit custom-code budget pass.
The shared model base is SDK-owned and absent from the current generated-file manifest. This change does not require regeneration.