[codex] Audit managed endpoint error context#3245
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 enriches error classes with additional context fields (operation, stage, userId, environmentId, etc.) for better debugging and observability. No runtime behavior changes - errors are thrown at the same points with the same causes, just with more diagnostic information attached. You can customize Macroscope's approvability policy. Learn more. |
Summary
Why
The previous errors collapsed distinct managed endpoint failures into generic messages with only a cause. That made incidents difficult to correlate and, in two structural failure cases, encouraged artificial causes. The new schemas identify the exact failing operation and safe resource context while retaining real underlying failures.
Validation
Note
Medium Risk
Changes error types and mapping across Cloudflare tunnel/DNS provisioning and DB allocation paths; behavior is mostly observability, but callers or logs that assumed the old minimal error shape could break.
Overview
Relay managed endpoint failures now carry structured fields (operation, pipeline stage, user/environment, and relevant hostname/tunnel/DNS IDs) instead of generic messages with only a wrapped
cause.Allocation persistence maps each DB action to
ManagedEndpointAllocationPersistenceErrorwith explicitoperation/stage; unresolved reservations useresolve-reservationwithout inventing acause, while real DB errors still attach the original failure.Provisioning/deprovisioning threads the same pattern through
ManagedEndpointProvisioningFailed/ManagedEndpointDeprovisioningFailed(per-step stages likeensure-dns-record,delete-tunnel), enriches config/origin/client errors, validates malformed Cloudflare tunnel payloads atvalidate-tunnel-response, and switches not-found swallowing on delete to taggedcatchTagson tunnel/DNS client errors. Focused allocation and provider tests assert the new shapes and cause chaining.Reviewed by Cursor Bugbot for commit ebd3365. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add structured error context to managed endpoint provisioning and allocation errors
operation,stage, and identity fields (userId,environmentId, plus optional resource identifiers).ManagedEndpointAllocationsnow emitManagedEndpointAllocationPersistenceErrorwith explicitoperationandstage: 'database-request'; the unresolved-reservation branch emitsstage: 'resolve-reservation'without a synthetic cause.ManagedEndpointProvidernow wrap each phase with stage-specific errors; malformed tunnel responses are treated asstage: 'validate-tunnel-response'failures without a cause, skipping DNS operations.ignoreNotFoundis narrowed to tagged client error types and now rethrows the original tagged error when the cause is not a NotFound condition.causemay be absent on validation failures;isManagedEndpointAllocationPersistenceErrorhelper is removed.Macroscope summarized ebd3365.