[codex] Structure primary environment target failures#3413
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
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 refactors error handling to use structured, typed error classes instead of generic Error objects. The changes are mechanical - replacing error constructors and adding type guards - with no changes to when errors are thrown or core runtime behavior. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate dc98dcb
Summary
This is stacked on #3409 because both changes share the primary-environment barrel and bootstrap tests.
Validation
vp test apps/web/src/environments/primary/bootstrap.test.ts apps/web/src/authBootstrap.test.ts(23 tests)vp checkvp run typecheckNote
Medium Risk
Changes bootstrap/connection URL resolution and error surfaces at app startup; mis-handled throws could block connecting, though behavior is largely equivalent with clearer failures.
Overview
Primary environment target resolution now throws Effect Schema tagged errors instead of generic
Errorstrings, with fields for target source (configured,window-origin,desktop-managed), URL kind, protocol, or which desktop bootstrap URLs are missing.URL parsing goes through a shared
parseTargetUrlhelper that wrapsURLfailures inPrimaryEnvironmentUrlInvalidError, keeps the original parsercause, and avoids putting raw configured URLs in user-facing messages. Unsupported window protocols and partial desktop bootstrap data getPrimaryEnvironmentProtocolUnsupportedErrorandDesktopEnvironmentBootstrapIncompleteErrorrespectively.readPrimaryEnvironmentTargetis typed as always returning a target (desktop → configured → window origin), soresolvePrimaryEnvironmentHttpUrldrops the old null guard and the unreachable “unable to resolve HTTP base URL” error. The primary environment barrel re-exports the new error classes, type guards, andPrimaryEnvironmentTarget. Bootstrap tests cover invalid env URLs, missingwsBaseUrl, andfile:origins.Reviewed by Cursor Bugbot for commit dc98dcb. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace generic errors with structured typed errors for primary environment target failures
PrimaryEnvironmentRequestErrorin auth.ts, a Schema-backed tagged error carryingoperation,status,detail, optionalpairingLinkId/sessionId, andcause; replaces allBootstrapHttpErrorand genericErrorthrows across auth operations.PrimaryEnvironmentUrlInvalidError(sanitized message, no raw URL leakage),PrimaryEnvironmentProtocolUnsupportedError, andDesktopEnvironmentBootstrapIncompleteError.readPrimaryEnvironmentTargetnow returns a non-nullPrimaryEnvironmentTargetor throws a structured error; callers can no longer receivenull.Schema.is-based type guards (isPrimaryEnvironmentRequestError,isPrimaryEnvironmentUrlInvalidError, etc.) and exports all new types from index.ts.BootstrapHttpErroror checked fornullfrom target resolution must now handle the new error types.Macroscope summarized dc98dcb.