fix: return the error instead of dereferencing a None response on transport failures#564
Open
somethingnew2-0 wants to merge 1 commit into
Open
Conversation
… API template The generated API methods evaluate `response_body == '' or response.status == 204` before checking `error`. On a transport-level failure (dropped/reset connection, timeout) the request executor returns a None response with the error set, so `response.status` raises `AttributeError: 'NoneType' object has no attribute 'status'` instead of returning the error in the result tuple. Guard the dereference with an early `if response is None:` that returns the error, mirroring the existing create_request error handling. Only the null-response (transport) path changes; HTTP-error handling is unchanged. Regenerate okta/api/*_api.py via openapi-generator 7.7.0 to propagate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
somethingnew2-0
marked this pull request as ready for review
July 17, 2026 04:29
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.
Summary
The generated API methods raise
AttributeError: 'NoneType' object has no attribute 'status'on any transport-level failure, instead of returning the error in their(data, response, error)result tuple.Root cause
In
openapi/templates/api.mustache(so every generatedokta/api/*_api.pymethod), afterexecute()returns, the response is dereferenced before the error is checked:RequestExecutor.execute()returns(None, None, error)on failure, andHTTPClient.send_requestreturns(None, None, None, error)for anyaiohttp.ClientError/asyncio.TimeoutError. So a dropped/reset connection (e.g. aServerDisconnectedErrorfrom reusing a pooled keep-alive the server has closed) or a socket timeout yields aNoneresponse with the error set — andresponse.statusraises before the code ever inspectserror.Because it lives in the template, it affects every generated
list_*/get_*/ etc. method.Fix
Add an early guard that returns the error before the dereference, mirroring the existing
create_requesterror handling:Only the null-response (transport-failure) path changes — it now returns the error in the tuple as documented, instead of raising. HTTP-error handling (a non-None response carrying an error) is untouched.
Notes
okta/api/*_api.pyneed to be regenerated with the pinnedopenapi-generator-cli7.7.0 to propagate the fix; I wasn't able to run the JAR generation locally, so I've left that to the maintainers' pipeline. Happy to regenerate and/or add a regression test if you'd prefer it folded into this PR.executeresponse handling).🤖 Generated with Claude Code