[codex] Structure connection persistence failures#3255
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 Structural refactor of error types in connection persistence code. Replaces string-based error messages with typed error classes containing structured fields (operation, stage, resource, cause) for better debugging and observability. Error handling flow unchanged; new tests verify the structured error behavior. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 4d9e86a
Summary
Validation
vp test packages/client-runtime/src/platform/persistence.test.ts packages/client-runtime/src/connection/registry.test.ts apps/web/src/connection/storage.test.ts apps/mobile/src/connection/storage.test.ts apps/mobile/src/connection/migration.test.tsvp check(passes with existing unrelated warnings)vp run typecheckvp run lint:mobileStack
Note
Medium Risk
Broad changes to error shapes across web/mobile local connection persistence; recovery behavior is similar but callers that depended on old message strings or untyped causes may need updates.
Overview
Replaces ad-hoc string-built persistence errors with structured tagged errors whose user-facing
messageis stable and does not embed raw cause text.ConnectionPersistenceErrornow recordsstage,resource, optionalenvironmentId/threadId/path, andcause, with a computed message. Storage-layer failures map through new types (ConnectionStorageOperationError,IndexedDbUnavailableError,DesktopSecureStorageUnavailableError) andConnectionTransientError.fromStorageFailure, keeping the full failure chain oncause.Web and mobile connection storage/catalog paths are updated to construct these errors at each boundary (IndexedDB, desktop secure storage, Expo secure store, file caches). Catalog encode/decode uses shared Schema Effect codecs; corrupt-catalog recovery uses
Effect.catchTagsforConnectionTransientErroronly.LegacyConnectionMigrationErrorgainsstage(parse|decode) andcauseinstead of a free-form message.Tests assert cause preservation, stable messages, and that sensitive details stay out of surfaced strings.
Reviewed by Cursor Bugbot for commit 4d9e86a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure connection persistence failures with typed error classes across web and mobile storage
ConnectionStorageOperationError,IndexedDbUnavailableError,DesktopSecureStorageUnavailableError, and aConnectionTransientError.fromStorageFailurefactory inmodel.tsto standardize transient storage errors with stable, non-leaking messages.ConnectionPersistenceError(persistence.ts) with structured fields (operation,stage,resource,environmentId,threadId,path,cause) and a derived stable message.apps/web/src/connection/storage.ts) and mobile (apps/mobile/src/connection/storage.ts) storage layers, covering IndexedDB, secure storage, shell/thread cache, and catalog encode/decode paths.LegacyConnectionMigrationErrorwith structuredstageandcausefields inmigration.ts; onlyConnectionTransientErroris caught during corrupt-catalog recovery, allowing other error types to propagate.Macroscope summarized 4d9e86a.