Skip to content

fix(backend): preserve mock database read errors - #2048

Draft
woahwhattheheck wants to merge 1 commit into
Commitlabs-Org:masterfrom
woahwhattheheck:fix/1934-mockdb-read-errors-20261006
Draft

woahwhattheheck wants to merge 1 commit into
Commitlabs-Org:masterfrom
woahwhattheheck:fix/1934-mockdb-read-errors-20261006

Conversation

@woahwhattheheck

@woahwhattheheck woahwhattheheck commented Oct 6, 2026 •

Copy link
Copy Markdown

Closes #1934.

Only a missing mock database file now returns fresh empty collections. Invalid JSON and filesystem errors produce a content-free diagnostic through the existing logger and reject with the original error, instead of appearing to be an empty database. Valid record normalization and the existing write queue are preserved.

Adds four focused Vitest regressions for missing files, corrupted JSON, permission errors and valid records.

Current project validation on the exact submitted source: Node20.20.2, pnpm9.0.0, Vitest2.1.9, the unchanged project configuration/setup and default jsdom29.1.1 environment. All four focused regressions pass. Replacing only production mockDb.ts with the exact master preimage reproduces three failures and one pass; restoring the submitted postimage returns four passes. V8 coverage hits all seven mapped executable statements and all three mapped branch blocks in the changed read/error path (100%). Whole-module coverage is71.11% statements/lines,83.33% branches and50% functions because the unchanged write/reset path is outside this focused suite.

Dependency installation exposed an existing base inconsistency: package.json lists Prettier^3.9.6 but pnpm-lock.yaml omits it, so frozen install rejects the untouched base. For this local focused run only, that unlisted devDependency was temporarily omitted to install the exact existing lock with scripts disabled; package.json was then restored before testing. Source, package and lock readback are clean. No dependency change is included. Full project typecheck/build and hosted CI are not claimed.

Prior independent evidence for the same postimages also covered temporary real files and permission/logger doubles through actual production transpilation (Node22.16.0/TypeScript5.8.3): baseline1pass/3failures to candidate4passes.

Full source and reproducible evidence: https://github.com/woahwhattheheck/bounty-concierge/blob/fa5cb9b191b44af02b4f134a213fe354552151ba/deliveries/commitlabs-1934/ACCEPTANCE.md

Published production blob fcfbaf841fcb771af87970ae6acc5cd7ce814c00 and test blob 7be93fd7a6a85097f1c73ca4e65baddbd0278762 match that packet exactly. Head cfeb4ffc82faaf5dbeabd3ed40eeefbf170a9632 is one commit ahead of current master 0d847032ef5862806cbb678f0bca93b6be44fb17; exactly two files (+49/-2).

Focused project command: pnpm exec vitest run src/lib/backend/__tests__/mockDb.test.ts.

@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@woahwhattheheck is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

src/lib/backend/mockDb.ts has no tests and swallows all read errors identically to 'no data'

1 participant