fix: coerce exception code to string or None - #3611
Open
Rajeev91691 wants to merge 1 commit into
Open
Conversation
ting-hong-shieh
left a comment
There was a problem hiding this comment.
Reviewed b00a48a against #3531. The focused regression passes, and the normalization keeps the public str | None contract intact. One reproducible formatting failure remains below. No API call or external service was used.
Validation snapshot:
- Focused pytest: 1 passed, 176 deselected.
- Ruff 0.14.7 check: passed.
- Ruff 0.14.7 format check: failed because tests/test_client.py would be reformatted.
- git diff --check: failed at tests/test_client.py:2971.
| # Test None code | ||
| err = APIError("message", request, body={"code": None}) | ||
| assert err.code is None | ||
|
|
There was a problem hiding this comment.
Please remove this extra blank line at EOF. Using the repository-pinned Ruff 0.14.7, ruff format --check src/openai/_exceptions.py tests/test_client.py reports that this file would be reformatted; git diff --check independently reports tests/test_client.py:2971: new blank line at EOF. The focused regression itself passes (1 passed, 176 deselected).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Coerce error code inside APIError body to str | None to prevent validation errors with construct_type when the API returns integer codes (e.g. 400). Added unit test in tests/test_client.py.