fix: an error should say what the server said - #19
Merged
Conversation
For 401, 402, 404 and 429 the client replaced the server's message with a canned hint and dropped the rest. That removes the only part that tells causes apart: a 401 for a credential that was rejected read exactly like a 401 for one that never arrived, and there was no way to know which without guessing. The hint stays — it is the useful half — and the server's own words follow it. The 401 hint now also depends on which credential the client carries. An OAuth-authenticated caller has no API key to check, so telling them to find one is a wrong turn rather than a vague one. That happened today: a model read "bad or missing API key" from a remote MCP server, and dutifully advised setting KHWAN_API_KEY on a path that has never used one.
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.
For 401, 402, 404 and 429 the client replaced the server's message with a canned hint and dropped the rest:
That removes the only part that tells causes apart. A 401 for a credential that was rejected read exactly like a 401 for one that never arrived — the engine distinguishes them (
Invalid bearer tokenvsMissing credentials) and the client threw that away.After
The hint stays, because it is the useful half. The server's own words follow it.
The 401 hint depends on the credential
An OAuth-authenticated caller has no API key to check, so sending them to look for one is a wrong turn rather than a vague one.
That happened today: a model read "bad or missing API key" from a remote MCP server and dutifully advised setting
KHWAN_API_KEY— on a path that has never used one, and where the real question was whether the token had expired.6 new tests, 41 passing.