Skip to content

Remove persistence error constructor wrappers#3398

Merged
juliusmarminge merged 2 commits into
mainfrom
codex/remove-persistence-error-wrappers
Jun 20, 2026
Merged

Remove persistence error constructor wrappers#3398
juliusmarminge merged 2 commits into
mainfrom
codex/remove-persistence-error-wrappers

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Removes the valueless persistence error constructor wrappers and constructs SQL errors directly where operation and cause are known. Generic duplicated detail text is dropped; specific detail remains supported. SchemaError conversion moves to the valueful PersistenceDecodeError.fromSchemaError mapper.

Validation:

  • vp test persistence Errors, projection repositories, event store, and orchestration engine suites (19 tests)
  • vp test server and SessionStore suites (104 tests)
  • vp check
  • vp run typecheck

Note

Low Risk
Localized persistence error construction and logging shape changes; no auth or data-path logic changes, with tests covering message and diagnostic behavior.

Overview
Persistence repositories now build PersistenceSqlError and PersistenceDecodeError directly instead of going through thin toPersistence* wrappers. PersistenceSqlError.detail is optional, so messages like SQL error in <operation> no longer append a generic “Failed to execute …” suffix when only operation and cause are known.

Schema failures are mapped via PersistenceDecodeError.fromSchemaError(), which summarizes issues with a small summarizeSchemaIssue helper (issue tags only) rather than the full default formatter—so rejected row/payload values are not copied into issue or message. toPersistenceDecodeCauseError is removed; legacy toPersistenceSqlError / toPersistenceDecodeError remain for orchestration/projection call sites. New tests lock in SQL message shape and decode diagnostics that exclude sensitive rejected data.

Reviewed by Cursor Bugbot for commit dd36e26. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Remove persistence error constructor wrapper functions in favor of direct error instantiation

  • Replaces toPersistenceDecodeError and toPersistenceSqlError helper calls with direct construction via PersistenceDecodeError.fromSchemaError(operation, cause) and new PersistenceSqlError({ operation, cause }) across persistence repositories.
  • Adds summarizeSchemaIssue in Errors.ts to produce compact issue strings from SchemaIssue.Issue, avoiding rejected payload values leaking into error diagnostics.
  • Makes PersistenceSqlError.detail optional; messages now read 'SQL error in <operation>' when no detail is provided (previously always included a detail string).
  • Behavioral Change: decode error messages now use summarized issue strings instead of the full SchemaIssue formatter output; SQL errors constructed via the new path omit the 'Failed to execute <operation>' detail string.

Macroscope summarized dd36e26.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 806cc354-deb4-4df9-b0cc-07d36c152c71

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/remove-persistence-error-wrappers

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Mechanical refactoring that replaces curried error constructor wrappers with direct constructor/static method calls. Changes maintain backwards compatibility, add unit tests, and include a privacy improvement to avoid leaking payload data in error diagnostics.

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/remove-persistence-error-wrappers branch from 52640c0 to 3a877d2 Compare June 20, 2026 15:25
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 15:25

Dismissing prior approval to re-evaluate 3a877d2

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 17:06

Dismissing prior approval to re-evaluate dd36e26

@juliusmarminge juliusmarminge merged commit 9c98cd6 into main Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/remove-persistence-error-wrappers branch June 20, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant