Skip to content

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 into
microsoft:mainfrom
HardMax71:fix/empty-error-body-status-and-span
Sep 25, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
HardMax71:fix/empty-error-body-status-and-span

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

An error response with a registered error class but no body (a 503 from a gateway, with no Content-Type) raised APIError with 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. The get_object_value span was started before the no-body check and ended only after get_object_value returned, 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 a finally, as get_root_parse_node does 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 in 503, and a new parametrized test checks that no span started in throw_failed_responses stays open when there is no body, a body, or a body that fails to deserialize. The existing not-APIError test now checks the full message. 4 of these fail on main.
  • Full package: 160 passed. yapf, isort, mypy and pylint (10/10) clean on kiota_http.
  • The repro in Error response without a body: message ends in <class 'NoneType'> and the get_object_value span is never ended #755 against this branch prints failed to deserialize: 503 and spans never ended: [].

…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.
@HardMax71
Max Azatian (HardMax71) requested a review from a team as a code owner September 25, 2026 15:27
Copilot AI lite review requested due to automatic review settings September 25, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The reviewed changes address the reported issue with regression coverage and have no unresolved blocking concerns.

Review effort: Lite
Findings: None

@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Sep 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@baywet
Vincent Biret (baywet) merged commit 480ad44 into microsoft:main Sep 25, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

Error response without a body: message ends in <class 'NoneType'> and the get_object_value span is never ended

3 participants