Repository navigation
fix(rpcsmartrouter): send the request's lava-* headers when the router refuses it before asking any provider (MAG-5076) - #755
Open
avitenzer wants to merge 1 commit into
Conversation
…r refuses it before asking any provider (MAG-5076)
A request the router ended before it dispatched anything got the router's error with no lava-*
header at all. That covers a lava-select-provider pin on a provider the router cannot use (blocked,
out of rotation, without the add-on, a backup), plain or strict, answered 500 "Selected provider
not available"; a router with no provider to ask ("No pairings available."); and a deadline before
the first dispatch. The guid was only in the body and lava-user-request-type was lost. Part I §1
of the error rulebook puts Lava-Guid on every reply over HTTP and gRPC; Part IV §4 row 18 lists
the pinned case under MAG-5076.
SendParsedRelay returned nil for these, before appendHeadersToRelayResult ran. It now returns a
result that carries only the request's headers: Lava-Guid, lava-user-request-type,
Lava-Relay-Timeout-Applied when lava-relay-timeout was sent, Lava-Extension-Unavailable, and the
stateful and debug headers. No attempt went out, so there is no Lava-Provider-Address and no
Lava-Retries. Every listener sends the status and body it sent before: on this path the HTTP
listeners only pass the result's headers on, and gRPC sends them as trailers. The 400 for a pin
name the router does not have (MAG-3800) already carried Lava-Guid; it now carries the rest too.
WebSocket is unchanged.
A cross-validated request is left out: its pre-dispatch failures have their own reply
(crossValidationFailFast), and the header builder would count a round that never ran.
smartrouter_consistency_total and _failed_total now count these requests as failed, as they count
every failed reply the header builder sees.
Verified: TestFailedRelayReply_ARequestRefusedBeforeDispatchKeepsTheRequestHeaders_MAG5076 sends a
plain pin, a strict pin and a request to a router with no provider through the JSON-RPC, REST,
Tendermint RPC and GraphQL listeners; on main all 12 cases fail with "the reply carries no
Lava-Guid". TestGRPCListener_ARefusedPinCarriesTheRequestHeaders_MAG5076 does the same for both gRPC
refusals. TestSelectProvider_ANameTheRouterDoesNotHaveIsRefusedWith400 now also requires
lava-user-request-type on the 400 and the headers on the configured-but-unusable 500.
TestSendParsedRelay_ExpiredBeforeWriteDispatch pinned the header-less reply (require.Nil(result));
it now requires a result with the request type and no status. go test over rpcsmartrouter,
chainlib, routersession and relaycore passes, and the new tests pass 5 of 5 under -race.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Jira ticket: MAG-5076
What changes
A request the router ends before asking any provider now carries the request's own headers:
lava-select-providerpin on a provider the router cannot use (blocked, out of rotation, without the add-on, a backup), plain or strict: the 500Selected provider not available;No pairings available.;These replies carried no
lava-*header at all. The guid was only in the body, andlava-user-request-typewas lost. They now carryLava-Guid,lava-user-request-type,Lava-Relay-Timeout-Applied(whenlava-relay-timeoutwas sent),Lava-Extension-Unavailable, and the stateful and debug headers. There is still noLava-Provider-Addressand noLava-Retries: no attempt went out.Only headers change. Every interface sends the same status and body as before. The 400 for a pin name the router does not have (#725) already had
Lava-Guid; it now carries the rest too. gRPC gets them as trailers. WebSocket is unchanged.Why
The rulebook decides it: Part I §1 says
Lava-Guidgoes on every reply over HTTP and gRPC, and Part IV §4 row 18 lists the pinned case under this ticket. That answers the ticket's open question about a refusal made before dispatch.How
SendParsedRelayreturnednilfor these beforeappendHeadersToRelayResultran, the same shape #671 fixed for budget expiry. It now returns a result that carries only those headers. The listeners only pass a result's headers on along this path, so status and body cannot move.A cross-validated request is left out. Its pre-dispatch failures have their own reply (
crossValidationFailFast), and the header builder would count a round that never ran.Side effect:
smartrouter_consistency_total/_failed_totalnow count these requests as failed. They already count every failed reply the header builder sees.Not breaking
Headers are added to a reply that had none; no value changes. #671 did the same without
!.Docs follow-up:
docs/api/directives.mdandbackup.mdstill say a request that reached no node carries noLava-*headers. That is fixed in a docs PR stacked on docs#105, which rewrites the same lines.Tests
TestFailedRelayReply_ARequestRefusedBeforeDispatchKeepsTheRequestHeaders_MAG5076: a plain pin, a strict pin and a router with no provider, through the JSON-RPC, REST, Tendermint RPC and GraphQL listeners. On main all 12 cases fail with "the reply carries no Lava-Guid".TestGRPCListener_ARefusedPinCarriesTheRequestHeaders_MAG5076: both gRPC refusals (InvalidArgument and the provider-unavailable error). Both fail on main.TestSelectProvider_ANameTheRouterDoesNotHaveIsRefusedWith400: now also requireslava-user-request-typeon the 400, and the headers on the configured-but-unusable 500.TestSendParsedRelay_ExpiredBeforeWriteDispatchpinned the header-less reply (require.Nil(result)). It now requires a result with the request type and no status.go testoverrpcsmartrouter,chainlib,routersessionandrelaycorepasses. The new tests pass 5 of 5 under-race.go vet ./...andgolangci-lint --new-from-revare clean.Automation
test_a_pin_on_a_provider_in_no_pool_carries_the_request_headersstill carries the closed ticket's marker, and its arrangement predates #725. Its pinno-such-provideris now the 400Selected provider is not configured, so its precondition (500,Selected provider not available) fails as soon as #725 deploys. Once this PR deploys, both headers are present on that 400 and on the provider-unavailable 500. The test needs a configured provider the router cannot use (for example a backup) and its marker removed.🤖 Generated with Claude Code