fix: report host_not_found when a host JWT names an unknown host - #36
Open
Karavil wants to merge 2 commits into
Open
fix: report host_not_found when a host JWT names an unknown host#36Karavil wants to merge 2 commits into
Karavil wants to merge 2 commits into
Conversation
The middleware's host branch raised AGENT_NOT_FOUND when `iss` resolved to no host row, which points the operator at the agent record while the host row is the one missing. HOST_NOT_FOUND already exists and the routes use it for this same condition. The agent branch is untouched, so a genuine agent miss still reports AGENT_NOT_FOUND.
Karavil
marked this pull request as ready for review
August 4, 2026 02:25
Drops the `as any` cast on the test instance and routes both assertions through the existing expectError helper. Behaviour is unchanged.
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 failure
A host authenticates with a
host+jwtwhoseissresolves to no host row -- the host was never registered, was revoked, or its row is not reachable by the identifier being sent. The middleware answersagent_not_found.That sends the operator to look at the agent record, which is usually fine, while the host row is the thing that is missing.
HOST_NOT_FOUNDalready exists inAGENT_AUTH_ERROR_CODESand the routes use it for exactly this condition, so the two paths disagree on what to call the same state.The change
One line in the host branch of
createAgentAuthBeforeHook. The agent branch is untouched, so a genuine agent miss still reportsagent_not_found.This is a behavioural change to a response body, so it is worth a note in release notes -- a client matching on the
agent_not_foundstring for this case would need to also accepthost_not_found.Tests
Two cases in
host-not-found-error.test.ts: an unknown host on ahost+jwtreportshost_not_found, and an unknown agent on anagent+jwtstill reportsagent_not_found. Reverting the one-line change fails the first and leaves the second passing.Full suite: 258 passed, 15 files.
tsc --noEmitclean.Independent of #35, which fixes why a spec-compliant kid-less host lands in this branch at all. Either can merge first.