[Bug]: SQLError Failed to execute OrchestrationCommandReceiptRepository.upsert.query #4818
Sy-D(GitHub profile, opens in a new tab) added labelsbug
Sy-D(GitHub profile, opens in a new tab) added labelsneeds-triage
juliusmarminge closed this
Sign in to join this conversation.
I dug into this against
1b4830ff0. Short version: the message cannot show its own cause, so the screenshot alone can never identify the root failure.Why the message is empty of information#
apps/server/src/persistence/Errors.ts:41apps/server/src/persistence/Errors.ts:76detailrestatesoperation, so the rendered message is the operation name twice. The real failure is captured incause, it just never reaches the message.Worth noting:
Errors.test.tsalready contains a test named "keeps SQL operation context without a tautological detail", which constructs the error without a detail and asserts the message isSQL error in AuthSessionRepository.list:query. The intent is documented and tested;toPersistenceSqlErroris the path that does not honour it, and it is the path this repository uses.Which call site produced it#
Two callers of
OrchestrationCommandReceiptRepository.upsert:OrchestrationEngine.ts:281— the rejected-command path, which ends in.pipe(Effect.catch(() => Effect.void)). It cannot surface anything.OrchestrationEngine.ts:190— the accepted-command path, running insidewithTransactionalongsideeventStore.appendand the projection pipeline.So this came from the accepted path, mid-transaction.
What I deliberately cannot conclude#
The underlying cause. Given the upsert runs inside a transaction with other writers,
SQLITE_BUSY/ "database is locked" is plausible. So is aRequestschema encode failure, whichtoPersistenceSqlErrorwould relabel as a "SQL error" despite not being one. Those two want opposite fixes, and the current message cannot distinguish them — which is presumably why this is filed as not reproducible.Proposed first step#
Make the failure diagnosable: drop the tautological detail and surface the actual cause instead, so the next occurrence names
SQLITE_BUSYor the parse failure outright.Two things I would want a maintainer's view on before opening a PR:
toPersistenceSqlErrorshapes every persistence error message in the app. The diff is small; the effect is broad.cause.messageblindly.This would not fix the SQL failure itself — it makes it findable. Happy to open that PR if the direction is agreeable, and to follow up on the real cause once an occurrence reports one.