Conversation
0xGr1mm
force-pushed
the
fix-note-endpoint-status-codes
branch
from
September 4, 2026 14:55
defacf7 to
41e70d4
Compare
`/get_note` and `/send_note` answered every failure with `400 Bad Request`, including failures the caller has no part in. `SendNoteError::NoteTransportError` wraps the note transport client, and none of `NoteTransportError`'s variants describes a bad request: `Disabled` is a faucet started without a transport URL, and `Connection`, `Network`, `Deserialization` and `PaginationDidNotTerminate` are all the upstream service being unreachable or answering unusably. Reporting them as 4xx means an outage of that dependency is recorded as the caller's fault, so it does not show up in server error rates and tells clients not to retry. `NoteNotFound` was also a 400 on both endpoints, although the note id parsed and the request was well formed. Map them to what they are: 404 for a note that is not cached, 501 for a transport layer that was never configured, 502 for one that failed. The frontend switches on 400, 429, 500 and 503 and falls back to a generic failure for anything else, so the new codes take that path instead of telling the user their request was invalid. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0xGr1mm
force-pushed
the
fix-note-endpoint-status-codes
branch
from
September 8, 2026 16:39
41e70d4 to
8669da4
Compare
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.
Summary
/get_noteand/send_noteanswer every failure with400 Bad Request, including failures the caller has no part in. The most consequential case is the note transport layer.SendNoteError::NoteTransportErrorwraps the transport client, and none ofNoteTransportError's variants describes a bad request:DisabledConnectionNetworkDeserializationPaginationDidNotTerminateAll five are server-side or upstream conditions, and all five currently surface as
400. So while the note transport service is down, every/send_notecall is recorded as a client error: it does not appear in server error rates, and it tells clients and proxies that retrying is pointless.Disabledhas the same problem in a different way — it is a deployment that never configured the endpoint, which no caller can fix by changing their request.NoteNotFoundwas also a400on both endpoints, even though the note id parsed and the request was well formed. The note is either not from this faucet or has been pruned from the cache afterNOTE_RETENTION_BLOCKS.Change
Give each failure the status it deserves:
NoteNotFound→404 Not Found(both endpoints)NoteTransportError::Disabled→501 Not ImplementedNoteTransportError→502 Bad GatewayInvalidNoteIdstays400Both error types now carry a
status_codemethod, matching the shapeGetTokenErroralready uses inget_tokens.rs.Frontend
app.jsswitches on 400, 429, 500 and 503 and sends everything else toshowRequestFailedError, so the new codes take that generic path. That is also an improvement in what the user sees: a transport outage currently renders as "Invalid request".Tests
Six unit tests covering each mapping, including both an upstream failure and the disabled case.
cargo test -p miden-faucet --bins— 21 passed.frontend_mint_tokensfails in my environment becausechromedriveris not installed; it is unrelated to this change and fails the same way on a cleannext.cargo clippy -p miden-faucet --all-targets --all-features -- -D warnings— cleancargo +nightly fmt— cleanNote that this changes response codes on two public endpoints, so tell me if you would rather treat it as breaking and note it as such in the changelog.