Repository navigation
node: do not retry a provider that does not attest the required labels - #954
Merged
Merged
Conversation
When a provider's credential did not attest a label the caller required, or one of the egress floor, connectMCPSessionWithRetry treated the refusal as a failure to reach the peer. It ran the handshake three times, waited 1s and 2s between attempts, and returned "failed after 3 retries". The provider presents the same credential on every attempt, so the answer cannot change. checkProvider now wraps a failed label check in ErrLabelsNotSatisfied, and the retry loop stops on it as it does on ErrProviderNotGranted. An authorizer that stopped at a run limit is not wrapped, so a timeout is still retried. In TestCallMCPTool_LabelEnforcement and TestCallMCPTool_EgressFloorEnforcement the refused call took about 3.4s and now takes about 0.4s.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new error, ErrLabelsNotSatisfied, to represent cases where a provider's credentials do not satisfy the required labels or egress floor. It updates checkProvider to wrap authorization errors with this new error and modifies connectMCPSessionWithRetry to prevent retries when this error is encountered. Additionally, integration tests in mcp_handlers_test.go are updated to assert this behavior. I have no further feedback to provide as there are no review comments to evaluate.
aojea
approved these changes
Nov 26, 2026
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.
Same reasoning as #722, for the label check: when a provider's credential does not attest a label the caller requires, or one of the egress floor,
CallMCPToolno longer retries the call.connectMCPSessionWithRetrystops onErrAuthRejectedandErrProviderNotGranted, but a failed label check incheckProvidercarried neither, so it was retried as if the peer could not be reached. The provider presents the same credential on every attempt, so the call ran three handshakes, waited 1s and 2s, and returnedfailed after 3 retries: provider ... does not attest every label of ....This adds
ErrLabelsNotSatisfied, whichcheckProviderwraps around a failed label check, and the retry loop stops on it. An authorizer that stopped at a run limit is not wrapped, so a timeout is still retried and the facts and iterations limits keep their own handling from #842.Measured in Docker (
golang:1.26):TestCallMCPTool_LabelEnforcement(caller requiresregion=na-us)failed after 3 retriesTestCallMCPTool_EgressFloorEnforcement(floorjurisdiction=eu)failed after 3 retriesBoth tests now check
errors.Is(err, ErrLabelsNotSatisfied)and that the call was not retried. They fail without the change, and still fail with only themcp.goline reverted.Not changed: the HTTP label gate (
VerifyProvider) still answers 403, and its messages are unchanged.Tested in Docker (
golang:1.26):go test ./internal/node/...,go test -race -count=5on theTestCallMCPTool_*,TestCheckPeerLabels*,TestLabelGate*andTestVerifyPeerLabels*tests,go vet, andgolangci-lintv2.14.0.