ms-teams-cli icon indicating copy to clipboard operation
ms-teams-cli copied to clipboard

A response that will not deserialize reports only "error decoding response body"

Open aberoham opened this issue 3 months ago • 0 comments

teams presence get reported this against a real account:

API error (200): Failed to parse API response: error decoding response body

The response was a perfectly good 200. What failed was deserialization, and the message names neither the field, the value, nor where in the body it sat. Diagnosing it meant capturing the response by hand — which is how #69 came to need a live account to find a one-word type error.

The detail exists and is discarded. reqwest::Error keeps serde's account of the mismatch one level down its source chain, and Display never reaches it. A wiremock probe against the exact body that produced #69:

WHAT_THE_USER_SEES = Failed to parse API response: error decoding response body
SOURCE[1]          = invalid type: map, expected a string at line 1 column 66

SOURCE[1] is the whole diagnosis.

Six call sites report a parse failure to the user and all six lose it the same way:

  • src/api/client.rs:509 — every Graph response the CLI deserializes
  • src/auth/device_code.rs:65 — the device code response
  • src/auth/device_code.rs:96 — each token poll
  • src/auth/client_credentials.rs:38
  • src/auth/refresh.rs:49
  • src/auth/auth_code_pkce.rs:182

src/auth/keyring.rs:52 is not affected: it parses with serde_json directly, whose own Display already carries the detail.

This is not specific to presence. Any future drift between Graph's schema and this crate's models surfaces as the same uninformative line.

Suggested fix: walk the source chain when rendering the error. No new dependency. serde_path_to_error would additionally name the field path rather than a byte offset, but that is a dependency added for error text alone, and the offset plus the type mismatch is already enough to act on.

aberoham avatar Aug 28 '26 15:08 aberoham