From b76adab7c8cbb7c6d63db8f144788e3630963b0b Mon Sep 17 00:00:00 2001 From: Junhyuk Lee Date: Wed, 29 Apr 2026 15:20:24 +0000 Subject: [PATCH] Advance OSS contribution for Bug: `by_alias: NoneType` in openai-python v2.24.0 when logging.DEBUG is enabled Nightly Codex produced a focused contribution for https://github.com/openai/openai-python/issues/2921. Constraint: Automated nightly run; keep changes small and reviewable. Confidence: medium Scope-risk: narrow Tested: See uploaded nightly artifacts and workflow logs. Not-tested: Maintainer CI beyond this workflow. --- NIGHTLY_CODEX_FINAL_ATTEMPT_1.md | 12 ++++++++++++ tests/test_models.py | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_1.md diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md new file mode 100644 index 0000000000..dca6433e6c --- /dev/null +++ b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md @@ -0,0 +1,12 @@ +Implemented a small test-only regression contribution. + +Changed: +- [tests/test_models.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/tests/test_models.py:575): adds coverage that `model_dump()` works when `by_alias` is left unset, locking the behavior needed for issue #2921. +- [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1): summarizes the work, tests, and remaining risk. + +Verified: +- `uv run pytest tests/test_models.py -k "compat_model_dump_allows_default_by_alias or compat_method_no_error_for_warnings"` +- `uv run pytest tests/lib/test_azure.py::TestAzureLogging::test_azure_api_key_redacted` +- `uv run ruff check tests/test_models.py` + +Note: `.codex-nightly-prompt.md` and `uv.lock` were already untracked before my changes; I left them untouched. \ No newline at end of file diff --git a/tests/test_models.py b/tests/test_models.py index 588869ee35..335e84ad4f 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -572,6 +572,15 @@ class Model(BaseModel): assert isinstance(model_dump(m, warnings=False), dict) +def test_compat_model_dump_allows_default_by_alias() -> None: + class Model(BaseModel): + foo: Optional[str] = Field(alias="FOO", default=None) + + m = Model(FOO="hello") + + assert model_dump(m) == {"foo": "hello"} + + def test_to_json() -> None: class Model(BaseModel): foo: Optional[str] = Field(alias="FOO", default=None)