[GH-ISSUE #3356] [Issue]: Server build fails on staging — TS2304 'Cannot find name lorebooksStorage' in characters.routes.ts #1819

Closed
opened 2026-10-21 05:42:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Jul 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3356

Originally assigned to: @SpicyMarinara, @kolacheee on GitHub.

Summary

The server package fails to build on staging (2.1.1): tsc reports TS2304: Cannot find name 'lorebooksStorage' three times in packages/server/src/routes/characters.routes.ts (lines 1360, 1393, 1404), so pnpm build / pnpm check exit with code 2. The app can still be started (the dev runtime transpiles per-file without a full type-check), but every build attempt fails and git fetch / re-pnpm install do not help.

Expected behavior

pnpm build (and pnpm check) complete successfully on a fresh staging checkout.

Actual behavior

packages/server build: src/routes/characters.routes.ts(1360,31): error TS2304: Cannot find name 'lorebooksStorage'.
packages/server build: src/routes/characters.routes.ts(1393,15): error TS2304: Cannot find name 'lorebooksStorage'.
packages/server build: src/routes/characters.routes.ts(1404,19): error TS2304: Cannot find name 'lorebooksStorage'.
packages/server build: Failed
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @marinara-engine/server@2.1.1 build: `node ./scripts/build.mjs`
Exit status 2

Steps to reproduce

  1. git checkout staging && git pull
  2. pnpm install
  3. pnpm build (or pnpm check)

→ the server build fails with the three TS2304 errors above. Reproduced by at least two users (Windows 11), and it is not OS-specific — it is a plain type error in the committed source.

Environment

  • Marinara Engine version: 2.1.1 (staging, HEAD 913ab5523)
  • Install type: source
  • OS + version: Windows 11 (the type error itself is platform-independent)
  • Browser or app shell: N/A (server build)

Logs, screenshots, or video

See the TS2304 block above.

Additional context

Root cause — a semantic merge conflict between two lorebook PRs that git could not detect textually:

  • #3349 (revert linked-lorebook native export) removed the module-level const lorebooksStorage = createLorebooksStorage(app.db) and the createLorebooksStorage import from characters.routes.ts. Those existed only to feed the export bundling that PR reverts, and on the branch's own base nothing else used them.
  • #3343 ("Embed into card") added the POST /:id/embedded-lorebook/embed handler, which uses lorebooksStorage (the three failing lines). It branched off the pre-revert state, where the const/import still existed.
  • #3343 merged (7ba6257ce) after #3349 (400dd4aff) without being rebased onto the post-#3349 tree. Because #3343's added usage lines and #3349's removed declaration lines sit in different parts of the file, git auto-merged with no textual conflict, producing a tree that references lorebooksStorage but never declares it. (This exact hazard was called out in #3349's PR description as a rebase interaction to reconcile.)

Suggested fix — re-introduce the storage handle the embed endpoint now depends on, in characters.routes.ts:

  1. Add the import: import { createLorebooksStorage } from "../services/storage/lorebooks.storage.js";
  2. Inside charactersRoutes, next to the other storage consts (const storage = … / characterGallery / personaGallery, ~line 544), add: const lorebooksStorage = createLorebooksStorage(app.db);

The revert only needed to drop the export-bundling helpers; the storage handle itself is legitimately used by the embed feature and should stay.

Does this corrupt lorebooks? No. This is a compile-time type error, not a data path:

  • Existing lorebooks are untouched. All normal lorebook operations (create / edit / assign / import / export / folders) run through lorebooks.routes.ts, which has its own separate createLorebooksStorage(app.db) instance (unaffected).
  • The only broken code is the "Embed into card" endpoint. If it were invoked at runtime it would throw a ReferenceError on the first lorebooksStorage reference — before any DB write — so even calling it cannot produce a partial or corrupt state.
  • The app still runs because the dev runtime transpiles without a whole-program type-check; only the tsc-based build gate fails.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Jul 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3356 Originally assigned to: @SpicyMarinara, @kolacheee on GitHub. ## Summary The **server package fails to build** on `staging` (2.1.1): `tsc` reports `TS2304: Cannot find name 'lorebooksStorage'` three times in `packages/server/src/routes/characters.routes.ts` (lines 1360, 1393, 1404), so `pnpm build` / `pnpm check` exit with code 2. The app can still be *started* (the dev runtime transpiles per-file without a full type-check), but every build attempt fails and `git fetch` / re-`pnpm install` do not help. ## Expected behavior `pnpm build` (and `pnpm check`) complete successfully on a fresh `staging` checkout. ## Actual behavior ``` packages/server build: src/routes/characters.routes.ts(1360,31): error TS2304: Cannot find name 'lorebooksStorage'. packages/server build: src/routes/characters.routes.ts(1393,15): error TS2304: Cannot find name 'lorebooksStorage'. packages/server build: src/routes/characters.routes.ts(1404,19): error TS2304: Cannot find name 'lorebooksStorage'. packages/server build: Failed ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @marinara-engine/server@2.1.1 build: `node ./scripts/build.mjs` Exit status 2 ``` ## Steps to reproduce 1. `git checkout staging && git pull` 2. `pnpm install` 3. `pnpm build` (or `pnpm check`) → the server build fails with the three `TS2304` errors above. Reproduced by at least two users (Windows 11), and it is not OS-specific — it is a plain type error in the committed source. ## Environment - Marinara Engine version: 2.1.1 (staging, HEAD `913ab5523`) - Install type: source - OS + version: Windows 11 (the type error itself is platform-independent) - Browser or app shell: N/A (server build) ## Logs, screenshots, or video See the `TS2304` block above. ## Additional context **Root cause — a semantic merge conflict between two lorebook PRs that git could not detect textually:** - #3349 (revert linked-lorebook native export) **removed** the module-level `const lorebooksStorage = createLorebooksStorage(app.db)` and the `createLorebooksStorage` import from `characters.routes.ts`. Those existed only to feed the export bundling that PR reverts, and on the branch's own base nothing else used them. - #3343 ("Embed into card") **added** the `POST /:id/embedded-lorebook/embed` handler, which **uses** `lorebooksStorage` (the three failing lines). It branched off the pre-revert state, where the const/import still existed. - #3343 merged (`7ba6257ce`) **after** #3349 (`400dd4aff`) without being rebased onto the post-#3349 tree. Because #3343's added *usage* lines and #3349's removed *declaration* lines sit in different parts of the file, git auto-merged with **no textual conflict**, producing a tree that references `lorebooksStorage` but never declares it. (This exact hazard was called out in #3349's PR description as a rebase interaction to reconcile.) **Suggested fix** — re-introduce the storage handle the embed endpoint now depends on, in `characters.routes.ts`: 1. Add the import: `import { createLorebooksStorage } from "../services/storage/lorebooks.storage.js";` 2. Inside `charactersRoutes`, next to the other storage consts (`const storage = …` / `characterGallery` / `personaGallery`, ~line 544), add: `const lorebooksStorage = createLorebooksStorage(app.db);` The revert only needed to drop the export-bundling *helpers*; the storage handle itself is legitimately used by the embed feature and should stay. **Does this corrupt lorebooks? No.** This is a compile-time type error, not a data path: - Existing lorebooks are untouched. All normal lorebook operations (create / edit / assign / import / export / folders) run through `lorebooks.routes.ts`, which has its own separate `createLorebooksStorage(app.db)` instance (unaffected). - The only broken code is the "Embed into card" endpoint. If it were invoked at runtime it would throw a `ReferenceError` on the first `lorebooksStorage` reference — **before any DB write** — so even calling it cannot produce a partial or corrupt state. - The app still runs because the dev runtime transpiles without a whole-program type-check; only the `tsc`-based build gate fails. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1819
No description provided.