Skip to content

Frontend shows JSON parse error when no papers exist yet #6

Description

@wconnell

Problem

When the app has no processed papers yet (outputs/index.json doesn't exist), the UI displays:

Failed to load papers
Unexpected token '<', "<!doctype "... is not valid JSON

Root cause

frontend/src/api/papers.ts:5 calls fetch('/outputs/index.json'). The Vite middleware in frontend/vite.config.ts only serves the file if it exists — otherwise it falls through and Vite serves index.html, which the frontend then tries to parse as JSON.

Expected behavior

Empty state should show a friendly "No papers yet — process one to get started" message (matching the existing empty-state UX in the CLI list command).

Suggested fix

  • In fetchIndex(), treat a 404 (or non-JSON response) as an empty index rather than throwing.
  • Or: have the Vite middleware return {"papers": []} with Content-Type: application/json when index.json doesn't exist.
  • Or: have the backend's /api/papers endpoint return an empty list, and switch the frontend to use it instead of reading outputs/index.json directly.

Repro

  1. Clone repo, install deps
  2. Start frontend + backend without processing any papers first
  3. Open UI — error appears

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions