From 39c124b4e992b96032cbfaf1c040624d37bbeb13 Mon Sep 17 00:00:00 2001 From: Junhyuk Lee Date: Thu, 30 Apr 2026 07:43:08 +0000 Subject: [PATCH 1/2] Advance OSS contribution for Unsupported content type: 'multipart/form-data' Nightly Codex produced a focused contribution for https://github.com/openai/openai-python/issues/2749. 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/lib/test_azure.py | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 83 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..8e70d19868 --- /dev/null +++ b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md @@ -0,0 +1,12 @@ +Implemented a focused regression test for issue #2749. + +Changed [tests/lib/test_azure.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/tests/lib/test_azure.py:157) to cover sync and async Azure `images.edit(...)`, asserting the deployment URL, multipart `Content-Type` with boundary, API key header, and multipart body fields. + +Added [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1) with summary, tests, and remaining risk. + +Verification: +- `uv run --with pytest --with pytest-asyncio --with pytest-xdist --with respx pytest tests/lib/test_azure.py -q` passed, 53 tests. +- `uv run --with ruff ruff format --check tests/lib/test_azure.py` passed. +- `uv run --with ruff ruff check tests/lib/test_azure.py` passed. + +No commit, fork, push, or PR was created. \ No newline at end of file diff --git a/tests/lib/test_azure.py b/tests/lib/test_azure.py index 52c24eba27..9332faf67b 100644 --- a/tests/lib/test_azure.py +++ b/tests/lib/test_azure.py @@ -154,6 +154,77 @@ def token_provider() -> str: assert calls[1].request.headers.get("Authorization") == "Bearer second" +@pytest.mark.respx() +def test_image_edit_uses_azure_deployment_multipart_request(respx_mock: MockRouter) -> None: + respx_mock.post( + "https://example-resource.azure.openai.com/openai/deployments/deployment-client/images/edits?api-version=2025-04-01-preview" + ).mock(return_value=httpx.Response(200, json={"created": 0, "data": []})) + + client = AzureOpenAI( + api_version="2025-04-01-preview", + api_key="example API key", + azure_endpoint="https://example-resource.azure.openai.com", + azure_deployment="deployment-client", + ) + client.images.edit( + image=b"Example data", + prompt="A clean product photo", + model="gpt-image-1", + ) + + calls = cast("list[MockRequestCall]", respx_mock.calls) + request = calls[0].request + + assert request.url == ( + "https://example-resource.azure.openai.com/openai/deployments/deployment-client/images/edits?api-version=2025-04-01-preview" + ) + assert request.headers["Content-Type"].startswith("multipart/form-data; boundary=") + assert request.headers["api-key"] == "example API key" + + content = request.read() + assert b'name="image"; filename="upload"' in content + assert b'name="prompt"' in content + assert b"A clean product photo" in content + assert b'name="model"' in content + assert b"gpt-image-1" in content + + +@pytest.mark.asyncio +@pytest.mark.respx() +async def test_image_edit_uses_azure_deployment_multipart_request_async(respx_mock: MockRouter) -> None: + respx_mock.post( + "https://example-resource.azure.openai.com/openai/deployments/deployment-client/images/edits?api-version=2025-04-01-preview" + ).mock(return_value=httpx.Response(200, json={"created": 0, "data": []})) + + client = AsyncAzureOpenAI( + api_version="2025-04-01-preview", + api_key="example API key", + azure_endpoint="https://example-resource.azure.openai.com", + azure_deployment="deployment-client", + ) + await client.images.edit( + image=b"Example data", + prompt="A clean product photo", + model="gpt-image-1", + ) + + calls = cast("list[MockRequestCall]", respx_mock.calls) + request = calls[0].request + + assert request.url == ( + "https://example-resource.azure.openai.com/openai/deployments/deployment-client/images/edits?api-version=2025-04-01-preview" + ) + assert request.headers["Content-Type"].startswith("multipart/form-data; boundary=") + assert request.headers["api-key"] == "example API key" + + content = request.read() + assert b'name="image"; filename="upload"' in content + assert b'name="prompt"' in content + assert b"A clean product photo" in content + assert b'name="model"' in content + assert b"gpt-image-1" in content + + class TestAzureLogging: @pytest.fixture(autouse=True) def logger_with_filter(self) -> logging.Logger: From 0df48f8ac9401653909bec835b672f3bfbfe5eb7 Mon Sep 17 00:00:00 2001 From: Junhyuk Lee <58055473+xodn348@users.noreply.github.com> Date: Thu, 30 Apr 2026 11:45:55 -0500 Subject: [PATCH 2/2] Remove nightly runner artifact from PR branch --- NIGHTLY_CODEX_FINAL_ATTEMPT_1.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_1.md diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md deleted file mode 100644 index 8e70d19868..0000000000 --- a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md +++ /dev/null @@ -1,12 +0,0 @@ -Implemented a focused regression test for issue #2749. - -Changed [tests/lib/test_azure.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/tests/lib/test_azure.py:157) to cover sync and async Azure `images.edit(...)`, asserting the deployment URL, multipart `Content-Type` with boundary, API key header, and multipart body fields. - -Added [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1) with summary, tests, and remaining risk. - -Verification: -- `uv run --with pytest --with pytest-asyncio --with pytest-xdist --with respx pytest tests/lib/test_azure.py -q` passed, 53 tests. -- `uv run --with ruff ruff format --check tests/lib/test_azure.py` passed. -- `uv run --with ruff ruff check tests/lib/test_azure.py` passed. - -No commit, fork, push, or PR was created. \ No newline at end of file