fix: a request asks for a representation the server can produce - #122
Merged
ShocOne merged 1 commit intoAug 26, 2026
Merged
Conversation
kiota builds a request's Accept header from the media types an operation's responses declare, and reaches the error responses when no success response offers one. An operation answering 204 therefore sends Accept: application/problem+json, and a server that produces that representation only when refusing answers 406 before serving the request. Prenormalize gains a fifth pass: an operation whose success responses declare no media type has the content of its error responses dropped, so no Accept header is built. The response is inlined rather than the shared component stripped, because one component answers many operations and those whose success response does declare a media type still need it. The error mappings the content also generates go with it, and cost the provider nothing: the generated error handling reads a status code and a message, which kiota's untyped error carries as well as a typed one. Also rewrites the Prenormalize doc comment to docs/comment-style.md: one paragraph per pass stating what it does and the generator behaviour it answers, with the run-specific measurement and the editorial asides removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ShocOne
deleted the
fix/a-request-asks-for-a-representation-the-server-can-produce
branch
August 26, 2026 14:17
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.
The defect
kiota builds a request's
Acceptheader from the media types an operation's responses declare, and reaches the error responses when no success response offers one. An operation answering204therefore sends:ThousandEyes refuses that before serving the request:
Reproduced against the live API with curl:
Accept: application/problem+json→ 406,Accept: application/json→ 204. The API itself is well behaved — DELETE 204, GET-after-delete 404, second DELETE 404.Reproduced in kiota 1.34.1 from a 20-line OpenAPI document, so this is generator behaviour and not one document's mistake.
Why it went unnoticed
tag— the only test that was passing — passes by accident. Its DELETE declaresapplication/jsonon the500response, so the union kiota builds happens to contain a type the server can produce:tagdeleteproblem+jsonapplication/jsonapplication/json, application/problem+jsoncredentialdeleteproblem+jsonproblem+jsonapplication/problem+json27 of the 35 pilot resources sent an error-only Accept on DELETE, and 44 of 327 Accept headers across the generated SDK. Every one of those tests would have failed at destroy however well its create worked.
The fix
A fifth
Prenormalizepass. An operation whose success responses declare no media type has the content of its error responses dropped, so kiota emits noAcceptheader — which is correct for a response with no body.The response is inlined rather than the shared component stripped: one component answers many operations, and those whose success response does declare a media type still need it. Only the
descriptionsurvives, which is the one member a Response Object must carry.The error mappings the content also generates go with it. That costs the provider nothing:
extract_kiota.goreadsGetStatusCode()andError(), which kiota's untypedApiErrorcarries as well as a typed one.Measured
Error-only Accept headers in the regenerated pilot SDK: 44 → 0. Total Accept headers 327 → 281;
tag's GET still carriesapplication/hal+json, application/json, and the shared component is untouched.Benchmark (
sh tf_acceptance_tests.sh):credentialwent fromDelete failed (HTTP 406)to passing. Full-suite number is in the thread below.Also in this PR
The
Prenormalizedoc comment is rewritten todocs/comment-style.md: one paragraph per pass saying what it does and the generator behaviour it answers, with the run-specific measurement ("roughly one generation in five") and the editorial asides removed.Verification
make check(90.7% total, sdkgen 88.4%) andgolangci-lint run(0 issues). Both new tests were confirmed to fail with the pass disabled. The pilot regenerates andpostcheckpasses.🤖 Generated with Claude Code