Problem
The /api/reports?session= endpoint serves artifacts exclusively from the local filesystem (reports/ directory + exports.json manifest). On new GCE instances created by MIG auto-healing or zone migration, the reports/ directory is empty — all artifacts from previous sessions exist only in the PostgreSQL report_artifacts table (persisted since v4.9.0).
Result: PDFs, DOCXs, charts, and Markdown files show "no documents available" for any session run on a prior instance, despite 309 artifacts across 5 sessions being present in the database.
Root Cause
/api/reports checked fs.existsSync(sessionPath) and returned { reportCount: 0, reports: [] } immediately when the directory was missing, never querying the database. The DB artifact endpoints (/api/db/artifacts/:id/download, /api/db/sessions/:sessionKey/artifacts) existed but were not wired into the reports flow that the frontend consumes.
Fix (v4.12.2)
- DB fallback branch in
claude-sdk-server.js: when filesystem session directory is missing, queries report_artifacts joined on sessions.session_key and returns artifacts with /api/db/artifacts/:id/download URLs
- PDF inline disposition in
dbFrontendRouter.js: PDFs served with Content-Disposition: inline to match existing /api/convert/download behavior (opens in-browser tab)
Files Changed
src/server/claude-sdk-server.js — DB fallback in /api/reports
src/server/dbFrontendRouter.js — PDF inline disposition
CHANGELOG.md — v4.12.2 entry
Verification Checklist
Labels
bug, deploy-week-4, database
Problem
The
/api/reports?session=endpoint serves artifacts exclusively from the local filesystem (reports/directory +exports.jsonmanifest). On new GCE instances created by MIG auto-healing or zone migration, thereports/directory is empty — all artifacts from previous sessions exist only in the PostgreSQLreport_artifactstable (persisted since v4.9.0).Result: PDFs, DOCXs, charts, and Markdown files show "no documents available" for any session run on a prior instance, despite 309 artifacts across 5 sessions being present in the database.
Root Cause
/api/reportscheckedfs.existsSync(sessionPath)and returned{ reportCount: 0, reports: [] }immediately when the directory was missing, never querying the database. The DB artifact endpoints (/api/db/artifacts/:id/download,/api/db/sessions/:sessionKey/artifacts) existed but were not wired into the reports flow that the frontend consumes.Fix (v4.12.2)
claude-sdk-server.js: when filesystem session directory is missing, queriesreport_artifactsjoined onsessions.session_keyand returns artifacts with/api/db/artifacts/:id/downloadURLsdbFrontendRouter.js: PDFs served withContent-Disposition: inlineto match existing/api/convert/downloadbehavior (opens in-browser tab)Files Changed
src/server/claude-sdk-server.js— DB fallback in/api/reportssrc/server/dbFrontendRouter.js— PDF inline dispositionCHANGELOG.md— v4.12.2 entryVerification Checklist
worktree-deploy-week-4c3a5ed55) in browser — verify PDFs/DOCXs/charts populateLabels
bug, deploy-week-4, database