From c8960fe8fc8802e71c1a28166c46e38fdfec70b0 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Thu, 16 Jul 2026 21:25:11 -0700 Subject: [PATCH] fix: return the error instead of dereferencing a None response in the 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 --- openapi/templates/api.mustache | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openapi/templates/api.mustache b/openapi/templates/api.mustache index 6b8cecbe..c4b22ab0 100644 --- a/openapi/templates/api.mustache +++ b/openapi/templates/api.mustache @@ -68,6 +68,21 @@ class {{classname}}(ApiClient): response, response_body, error = await self._request_executor.execute(request) {{/returnType}} + # A transport-level failure (e.g. a dropped/reset connection or a timeout) + # makes execute() return a None response with the error set. Return that + # error before dereferencing response below, otherwise response.status + # raises AttributeError: 'NoneType' object has no attribute 'status'. + if response is None: + {{#returnType}} + if {{returnType}} is Success: + return (None, error) + else: + return (None, None, error) + {{/returnType}} + {{^returnType}} + return (None, error) + {{/returnType}} + if response_body == '' or response.status == 204: response_data = RESTResponse(response) resp = ApiResponse(