Skip to content

projector: read/reconcile routes return unstructured 500s on store or runtime failures #10540

Closed

Description

@dezren39

Problem

Most pm-stack/projector HTTP routes let store, git, or reconcile exceptions propagate out of handleRequest, so a runtime failure becomes an unhandled fetch rejection and a framework-default 500 response with no JSON error body. This is inconsistent with the service's own /health and /github/webhook paths, which catch failures and return structured JSON responses.

Evidence

pm-stack/projector/src/server.ts:

  • GET /health (/api/health) catches probe failures and returns 503 JSON: L280-294 (try { ... } catch (e) { return jsonResponse(503, { ok: false, error: ... }) }).
  • POST /github/webhook validates input, guards apply/publish, records outcomes, and returns structured 4xx/5xx JSON on failures: L297-358.
  • Other routes do not guard store/runtime calls:
    • GET /items: L305-322 calls store.getItems / store.listItems without try/catch.
    • GET /comments: L325-340 calls store.getCommentsForSubject / store.getComments without try/catch.
    • GET /links: L346-351 calls store.getLinks without try/catch.
    • DELETE /links: L395-399 calls store.deleteLink without try/catch (POST's upsertLink is separately guarded at L384-388).
    • GET /subjects/*: L418-431 calls store.getSubject without try/catch.
    • GET /hot: L444-456 calls store.hotHighWater / store.listHotEvents without try/catch.
    • GET /hot/checkpoints: L458-463 calls store.getConsumerCheckpoint without try/catch.
    • POST /reconcile: L500-504 calls reconcileRepos(...) without try/catch.

serve() returns handleRequest(...) directly (L603-615), so thrown/rejected errors are not normalized into the service's jsonResponse shape.

Why it matters

Projector is an internal API consumed by other PM-stack components and operational tooling. DB contention/corruption, bad state, or reconcile failures can produce opaque/non-JSON 500s that are harder for clients and monitors to interpret than a consistent { "error": ... } response.

Suggested fix shape

Add a consistent error boundary for route handlers (or a top-level catch around handleRequest/serve fetch) that logs the failure and returns a structured JSON 5xx (e.g. jsonResponse(500, { error: ... })), while preserving existing specific status codes where already intentional. Keep the webhook's current semantics where appropriate.

Activity

  1. developing-today commented on Nov 15, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · verified already done — task 19321 (lane code-a)

  3. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    state: verified_closed / already_done
    task: 20652 (repo-health-code-pilot, lane oc-code-03)
    issue: #10540 — projector: read/reconcile routes return unstructured 500s

    Fresh check 2026-11-18: issue CLOSED (closed 2026-11-17T02:13:20Z). Commit 5757dba (projector: answer unhandled route errors with a JSON 500) is on origin/main; pm-stack/projector/src/server.ts handleRequest returns a JSON internal_error 500.

    Disposition: already_done, no follow-on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions