Repository navigation
re: refresh credentials when a proxy answers HTTP 401 - #3
jun-mercury wants to merge 1 commit into
Conversation
A credential helper's refresh never ran when Namespace refused a token. Its ingress answers a bearer it does not accept with HTTP 401 and a plain-text body, not with gRPC UNAUTHENTICATED. tonic 0.14.6 decodes that body before it looks at the HTTP status and returns INTERNAL, with the status only in the message (codec/decode.rs); its own 401-to-UNAUTHENTICATED mapping runs only at the end of a stream that decoded. A remote build on Namespace failed two minutes in on exactly this, on the bes-stack port of this change: "Failed to make BatchReadBlobs request: protocol error: received message with invalid compression flag: 105 (valid flags are 0 and 1) while receiving response with status: 401 Unauthorized". rpc_result now treats UNAUTHENTICATED, and INTERNAL or UNKNOWN whose message names status 401, as rejected credentials, so the existing invalidate and retry path runs. The message is matched because nothing structured carries the 401. Assisted-by: Claude:claude-opus-5-5
|
How we tested this, since the unit tests alone don't show it holds up against a real server. The live runs used the same change on our bes-stack port (mercury#51), not this branch. The logic is the same Setup. Each run was a single Runs on Namespace remote execution:
On this branch: Not covered: a rejection in the middle of a ByteStream or Execute/WaitExecution stream. Those retry loops don't refresh, here or on our port. Posted by Claude Code on behalf of Jun Matsushita. |
|
Is this not more a thing that should be fixed by Namespace? gRPC endpoint should serve gRPC; not 401s with non-gRPC content |
An ingress in front of the remote can answer a bearer it refuses with HTTP 401 and a plain-text body rather than gRPC UNAUTHENTICATED (LABPRIV-44, run E, 2026-09-26). tonic 0.14 decodes that body before it reads the status and returns INTERNAL with the 401 only in its message (codec/decode.rs), so the refusal read as a retryable INTERNAL and every retry carried the same cached token. `buck2_credential_helper::status_rejects_credentials` treats UNAUTHENTICATED, and INTERNAL or UNKNOWN naming status 401, as refused credentials; the RE client refreshes once per call on either, ahead of the reconnect test, and no longer retries a refusal it could not refresh. Ported from the lab line's 64289ce (cherry-picked from f17fb32, arianvp#3) onto the previous commit's port to the re_grpc stack. Execute and WaitExecution streams and ByteStream reads and writes keep their own retry loops, as on the lab line; a unary call's refresh clears the helper's shared cache they read from. The BES sink half is left out with the previous commit's. Change-Id: I243c4a2afe3da31a8d77813c53ed5b0b8b250f19 Assisted-by: Claude:claude-opus-5-5
…bounds Summary: # context Follow-up to the diff below (tracked gap): composable function types in type-parameter bounds still leak `ComposableFunctionN`. No prod instance — 0 changed jars in the fleet sample — but a fail-closed violation in the same family. # problem The real plugin's `ComposableTypeTransformer.visitTypeParameter` remaps every module type parameter's supertypes. We didn't, so bounds kept `ComposableFunctionN` in the erasure (`host(L...ComposableFunction0;)I`) and in class and method Signatures. # fix - Emulation: `ComposableTypeRewriter.visitTypeParameter` remaps bounds. - Native mirror, same diff: bounds counted and rewritten (`compose_types.rs`), function-type bound nullability (`type_parameters.rs`); `compose_type_bound.kt` moves from `refusals.d` to exact; 2 new probes. # fleet parity Full-universe Compose check (4,745 targets): stability rows 3,977 -> 1,048, applier 8,553 -> 8,533, 0 new rows, 0 unclassified; library and class ABI byte-identical 4,735/4,735 at every position (final re-gate, harness D133166871 V0.3 + D133182189 V0.2, independently reviewed: P1 FAIL unchanged; P2-P6, P8 and P10 PASS; P7 PASS; P9 FAIL declared intended omission (owner decision pending)). The table covers the stack through P6; the 7th adds the P7 run (73 bridge rows removed, 48 constructor-body-only changes under manifest; P7 PASS, library instruction-for-instruction match) and the 8th is fleet byte-identical (V0.4 PASS, 0 changed; direct byte comparison stands). Cumulative gate: FAIL, exit 1 -- 1 changed row (photorestyle `PlaybackStep`: test 1 -> 3 against backend 2, adding the matching known-stable bit while retaining an extra parameter-dependency bit (conservative direction: extra work, not an over-assertion); pre-existing #3 shape) and 1 inconclusive target (`composed`, unverifiable broken base). Reports: https://artifacts.internalmeta.com/a/4510517255827441 https://artifacts.internalmeta.com/a/2326985064801664 https://artifacts.internalmeta.com/a/1137597922586590 https://artifacts.internalmeta.com/a/2475838362823582 https://artifacts.internalmeta.com/a/2024183578261982 Reviewed By: jiawei-lyu Differential Revision: D133126208 fbshipit-source-id: 05bb01f2a36377a2914ee20ed6de235624870ba0
With this change, a credential helper's refresh also runs when an HTTP proxy in front of the remote refuses the token, not only when the gRPC server returns
UNAUTHENTICATED.rpc_resultnow treatsUNAUTHENTICATED, andINTERNALorUNKNOWNwhose message names HTTP status 401, as rejected credentials, so your existing invalidate-and-retry path runs.Why
Namespace's ingress answers a bearer it doesn't accept with HTTP 401 and a plain-text body. tonic 0.14.6 decodes that body before it looks at the HTTP status, and returns
INTERNALwith the status only in the message (codec/decode.rs). Its own mapping of 401 toUNAUTHENTICATEDonly runs at the end of a stream that decoded. We ported #1 onto MercuryTechnologies/buck2'sbes-stack(mercury#51). There, a remote build on Namespace failed two minutes in, when the helper handed out a token the ingress refused:The helper was never called again, and every retry carried the same cached token. The error message is matched as text because nothing structured carries the 401.
Proven and not
ActionCacheserver answers a refused bearer with HTTP 401 and a plain-text body.get_action_resultsends the first token, gets the 401, runs the helper again and succeeds with the second token.UNAUTHENTICATED-only guard, the helper test fails.cargo test -p remote_executionpasses (33 tests).bes-stackport only: the same check fixed the live Namespace run that had failed, and the 10-minute build succeeded after the refused token.rpc_result, so a refusal on a stream still doesn't refresh.Assisted-by: Claude:claude-opus-5-5