[codex] Structure relay environment link errors#3334
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR adds structured diagnostic fields (userId, environmentId, stage, cause) to environment link error objects for better debugging. The changes are purely additive and don't affect runtime behavior or control flow. You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
vp test infra/relay/src/environments/EnvironmentLinker.test.ts --no-cachevp checkvp run typecheckvpr typecheckOverlap audit
Note
Medium Risk
Touches JWT verification and nonce consumption on the environment-link path; behavior should match prior rejections but error shape and decode-path handling changed, which may affect API/logging consumers.
Overview
Relay environment linking now returns richer, stage-aware errors instead of generic invalid-proof failures.
EnvironmentLinkProofInvalidgainsuserId, astageliteral (e.g.decode_token,verify_proof,consume_proof_nonce), and an optionalcauseso JWT decode, schema decode, and verification failures are preserved rather than dropped. Payload decoding no longer usesEffect.optionthat swallowed errors—it maps failures todecode_payloadwith the underlying cause.EnvironmentLinkProofExpiredalso includesuserId, and every rejection path inlinksetsstage(andcausewhere applicable).Tests assert tampered proofs fail at
verify_proofwith aRelayJwtErrorcause, and replayed JTIs fail atconsume_proof_nonce.Reviewed by Cursor Bugbot for commit 4ea3e5b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add structured context fields and stage discriminants to
EnvironmentLinkerlink errorsEnvironmentLinkProofInvalidnow includesuserId, astageliteral (e.g.decode_payload,verify_challenge,consume_proof_nonce), and an optionalcause(underlying error).EnvironmentLinkProofExpirednow includesuserIdandenvironmentId, and its message reflects theenvironmentId.EnvironmentLinker.linkare updated to populate these fields, with cause propagation for JWT decode/verify errors.EnvironmentLinkProofInvalidand validate structured fields includingstageandcause._tag.Macroscope summarized 4ea3e5b.