fix(http): name the status code for an error without a body and end the get_object_value span - #756
Merged
Vincent Biret (baywet) merged 2 commits intoSep 25, 2026
Conversation
…he get_object_value span An error response with a registered error class but no body gave "failed to deserialize: <class 'NoneType'>". The message now ends in the status code, as in kiota-dotnet. The get_object_value span was started before the no-body check and ended only after a successful get_object_value, so it stayed open without a body and when deserialization raised; it is now started only when there is a body and ended in a finally. Fixes microsoft#755.
Vincent Biret (baywet)
approved these changes
Sep 25, 2026
Vincent Biret (baywet)
enabled auto-merge
September 25, 2026 19:04
|
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.



Overview
An error response with a registered error class but no body (a 503 from a gateway, with no
Content-Type) raisedAPIErrorwith the message... failed to deserialize: <class 'NoneType'>. The message now ends in the status code, as in kiota-dotnet and in the "no error class is registered for this code" messages of the same function. Theget_object_valuespan was started before the no-body check and ended only afterget_object_valuereturned, so it stayed open when there was no body and when deserializing raised. It is now started only when there is a body to deserialize, and ended in afinally, asget_root_parse_nodedoes with its own span.Related Issue
Fixes #755
Notes
When the registered error class is not an
APIError, the message used to name that class; it now shows the status code in that case too, matching kiota-dotnet.Testing Instructions
cd packages/http/httpx && pytest tests/test_httpx_request_adapter.py -k throw_failed_responses: a new test for an error response without a body checks the message ends in503, and a new parametrized test checks that no span started inthrow_failed_responsesstays open when there is no body, a body, or a body that fails to deserialize. The existing not-APIErrortest now checks the full message. 4 of these fail on main.kiota_http.failed to deserialize: 503andspans never ended: [].