[codex] Structure preview session key errors#3388
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 Straightforward error handling refactoring that replaces a plain Error with a structured TaggedErrorClass. The runtime behavior and error message remain unchanged; only the error type is now tagged for better Effect ecosystem integration. You can customize Macroscope's approvability policy. Learn more. |
Summary
The preview-session atom rejected malformed scoped thread keys with a generic
Error. Although the message included the raw key, the failure had no stable tag or structured field, so telemetry and error inspection could not distinguish this invariant from unrelated exceptions without parsing text.This change replaces that generic throw with a
Schema.TaggedErrorClasscarrying the malformedthreadKey. The message remains the same and is derived from that field. The validation and construction stay inline at the existing failure boundary, avoiding a constructor-only wrapper or an extra helper module.No behavior test was added for this pure internal-invariant refactor.
Validation
pnpm vp check(passes with existing repository warnings)pnpm vp run typecheckNote
Low Risk
Internal error-shape refactor only; same message and failure timing with no auth, data, or API behavior changes.
Overview
Malformed scoped thread keys in
previewSessionSyncAtomnow throwPreviewSessionThreadKeyParseError(EffectSchema.TaggedErrorClass) with a structuredthreadKeyfield instead of a plainError.The user-facing message is unchanged; the null check is tightened to
threadRef === null. Validation still happens at the same inline boundary inusePreviewSession.ts.Reviewed by Cursor Bugbot for commit 0455679. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace generic Error with typed
PreviewSessionThreadKeyParseErrorfor invalid preview thread keysIntroduces
PreviewSessionThreadKeyParseError, a tagged error class (viaeffect/Schema) with a structured shape and message, to replace the genericErrorthrown when an invalid scoped preview thread key is encountered inpreviewSessionSyncAtom. Also tightens the invalid key check from a falsy guard to an explicit=== nullcheck.Macroscope summarized 0455679.