Skip to content

fix: /api/reports returns empty for DB-persisted sessions on new instances #50

Description

@Number531

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

  • Commit and push to worktree-deploy-week-4
  • Rebuild Docker image and push to Artifact Registry
  • Rolling update on staging MIG
  • Load March 13 session (c3a5ed55) in browser — verify PDFs/DOCXs/charts populate
  • Verify PDF opens in new tab (inline disposition)
  • Verify current-session filesystem artifacts still load normally
  • Verify health endpoint returns 200

Labels

bug, deploy-week-4, database

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions