Skip to content

fix: type DatabaseError on pure-save and SQL/Pg store adapters - #854

Merged
patroza merged 2 commits into
mainfrom
fix/database-error-pure-save-and-sql
Aug 5, 2026
Merged

fix: type DatabaseError on pure-save and SQL/Pg store adapters#854
patroza merged 2 commits into
mainfrom
fix/database-error-pure-save-and-sql

Conversation

@omegent-app

@omegent-app omegent-app Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Why

Scanner production saw SchemaError "Expected InvalidStateError, got DatabaseError" because durable activities only allowed InvalidStateError while store adapters raise typed DatabaseError. App code can map/retry, but pure-save helpers omitted DatabaseError from their type channel (and SQL/Pg bulk paths still orDie'd), so the failure was erased at compile time and only appeared at runtime.

What

  • effect-app Repository/ext.ts: queryAndSavePure, saveManyWithPure, byIdAndSaveWithPure, extended save() / remove helpers, and repository request declare DatabaseError
  • infra SQL + Pg: runtime exec and bulkSetInternal map SqlError → DatabaseError with cause; preserve OCC/DatabaseError by _tag (not instanceof); seed/DDL remain orDie
  • vue: useAtomValue is Readonly<Ref> — wrap at call site; withDataFallback keeps no-options identity (tests)

How

Store adapters that fail with DatabaseError expose it on runtime paths; pure-save is query + pure + saveAndPublish and must not erase the channel. Callers with narrow activity error schemas fail compile until they map or orDie residual DatabaseError.

Remarks

Companion scanner PR: https://github.com/macs-holding/scanner/pull/2178 (durability + residual mapping; ships unlinked against registry until this publishes).

Co-authored-by: Patrick Roza 42661+patroza@users.noreply.github.com


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

omegent-app Bot and others added 2 commits August 5, 2026 09:15
queryAndSavePure / saveManyWithPure / byIdAndSaveWithPure and extended
save/remove helpers declare DatabaseError from saveAndPublish and query
instead of erasing it. SQL and Pg runtime exec/bulkSet map SqlError to
typed DatabaseError (preserve OCC by _tag). Repository request resolver
includes DatabaseError. Vue withDataFallback accepts useAtomValue's
Readonly Ref without an illegal ComputedRef cast.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Callers that need ComputedRef wrap useAtomValue first; restoring
identity preserves the documented no-options contract and tests.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@effect-app/cli

npm i https://pkg.pr.new/effect-app/libs/@effect-app/cli@854

effect-app

npm i https://pkg.pr.new/effect-app/libs/effect-app@854

@effect-app/eslint-codegen-model

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-codegen-model@854

@effect-app/eslint-shared-config

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-shared-config@854

@effect-app/infra

npm i https://pkg.pr.new/effect-app/libs/@effect-app/infra@854

@effect-app/vue

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue@854

@effect-app/vue-components

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue-components@854

commit: e8eaf22

@patroza
patroza merged commit 6312e40 into main Aug 5, 2026
6 checks passed
@patroza
patroza deleted the fix/database-error-pure-save-and-sql branch August 5, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant