Repository navigation
node: name the failed check in the label gate's 403 - #984
Conversation
The egress proxy chose the text of a label-gate refusal from what the caller sent rather than from what the provider's credential failed. A caller that sent X-Mesh-Required-Labels and reached a peer whose credential had expired, or was signed by an untrusted key, was told "Required labels not attested by provider". With an egress floor set, a peer with no credential at all was reported as not attesting the floor. The A2A gate answered "Required labels not attested by provider" for every refusal, including a provider not granted the service. labelGateDenial now reads the check from the error: ErrProviderNotGranted names the missing grant, ErrLabelsNotSatisfied names the caller's requirement or the floor, and anything else says the destination is not an enrolled peer. The egress proxy and the A2A gate both use it. Status codes are unchanged.
There was a problem hiding this comment.
Code Review
This pull request refactors the error reporting logic in the label gate by introducing a centralized helper function labelGateDenial in internal/node/labels_gate.go. This helper determines the specific reason for a 403 Forbidden response based on the verification error, required labels, and egress floor. The a2aEgressGate in a2a_service.go and createEgressProxy in sidecar.go have been updated to use this helper, reducing code duplication. Additionally, a comprehensive unit test TestLabelGateDenialNamesTheFailedCheck has been added to labels_gate_test.go to verify the correct error messages are returned for various failure scenarios. No issues were found, and there is no additional feedback to provide.
Follow-up to #954: now that a failed label check carries
ErrLabelsNotSatisfied, the label gate's 403 can name the check the provider's credential failed instead of guessing from what the caller sent.The egress proxy picked the text from the request: any refusal other than
ErrProviderNotGrantedbecame "Required labels not attested by provider" when the caller sentX-Mesh-Required-Labels, and "provider does not attest the egress floor" when a floor was set. The A2A gate answered "Required labels not attested by provider" for every refusal. The log line already had the real reason; only the text the caller sees was wrong.With the credentials
checkProvideractually refuses:labelGateDenialreads the check from the error, and the egress proxy and the A2A gate both use it. Status codes are unchanged.TestLabelGateDenialNamesTheFailedCheckcovers the six rows; the first three fail with the previous logic.Not changed here: the
CONNECTpath tries several providers and still answers "Required labels not attested by provider" when any of them refused, since each may have refused for a different reason.Tested in Docker (
golang:1.26):go test ./internal/node/...,go test -raceon the label gate, A2A and egress proxy tests,TestUngrantedServiceIsNeitherPublishedNorServedandTestA2ACUJfromtests/integration,go vet, andgolangci-lintv2.14.0.