Skip to content

Support non standard http codes#1407

Open
Ykrej wants to merge 11 commits into
openapi-generators:mainfrom
Ykrej:support-non-standard-http-codes
Open

Support non standard http codes#1407
Ykrej wants to merge 11 commits into
openapi-generators:mainfrom
Ykrej:support-non-standard-http-codes

Conversation

@Ykrej
Copy link
Copy Markdown

@Ykrej Ykrej commented Feb 27, 2026

Summary

Added support for responses with non-standard HTTP Status Codes. Off by default, enabled with allow_int_response_codes.

Problem

Currently if a response with a status code that does not exist in http.HTTPStatusCode a ValueError is raised. For example: ValueError: 490 is not a valid HTTPStatus.

Edge Case

If a non-standard status code is received from an endpoint that doesn't define any responses with non-standard status codes the old behavior will appear.

@Ykrej Ykrej marked this pull request as draft February 27, 2026 06:40
@Ykrej Ykrej marked this pull request as ready for review February 27, 2026 06:48
sergioestebance added a commit to langwatch/langwatch that referenced this pull request May 29, 2026
…T client

Cloudflare (520-527), AWS WAF (561), and other proxies return status codes
outside Python's http.HTTPStatus enum. The upstream openapi-python-client
template blindly calls HTTPStatus(response.status_code) in _build_response,
which raises ValueError on those codes and crashes every endpoint call.

Customer report: Cloudflare 520 from get_api_prompts_by_id.

Fix:
- Add safe_http_status() helper in types.py that falls back to int on ValueError
- Widen Response.status_code type from HTTPStatus to HTTPStatus | int
- Override openapi-python-client Jinja templates (openapi-templates/) so
  future regenerations preserve the fix; wire --custom-template-path in Makefile
- Apply the patch to all 90 already-generated endpoint files in place
- Regression test for 520, 561, 499 and IANA codes

Tracked upstream: openapi-generators/openapi-python-client#1407
sergioestebance added a commit to langwatch/langwatch that referenced this pull request May 29, 2026
…T client

Cloudflare (520-527), AWS WAF (561), and other proxies return status codes
outside Python's http.HTTPStatus enum. The upstream openapi-python-client
template blindly calls HTTPStatus(response.status_code) in _build_response,
which raises ValueError on those codes and crashes every endpoint call.

Customer report: Cloudflare 520 from get_api_prompts_by_id.

Fix:
- Add safe_http_status() helper in types.py that falls back to int on ValueError
- Widen Response.status_code type from HTTPStatus to HTTPStatus | int
- Override openapi-python-client Jinja templates (openapi-templates/) so
  future regenerations preserve the fix; wire --custom-template-path in Makefile
- Apply the patch to all 90 already-generated endpoint files in place
- Regression test for 520, 561, 499 and IANA codes

Tracked upstream: openapi-generators/openapi-python-client#1407
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