Skip to content

fix(web): handle missing analytics data on every page - #15

Merged
mxriverlynn merged 5 commits into
mainfrom
fix/web-no-data
Sep 22, 2026
Merged

mxriverlynn merged 5 commits into
mainfrom
fix/web-no-data

Conversation

@mxriverlynn

@mxriverlynn mxriverlynn commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Every data page in skillwalker-web returned a plain-text 500 when the analytics data directory was missing, empty, or only partly populated. The client then showed SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON instead of its empty-state message.

Why it broke

  • The data queries read parquet files with DuckDB without checking they exist. DuckDB throws IO Error: No files found that match the pattern ....
  • The SCIL/ACIL routes guarded for No such file or directory, which DuckDB never produces. The route tests passed only because they mocked that invented message. The test-runs and analytics routes had no guard.
  • With no onError handler, Hono sent plain text. The pages called res.json() without checking res.ok.

Changes

  • Data layer (packages/data): the queries check which parquet files exist before reading them.
    • List queries return [].
    • Detail queries throw the existing "run not found" error.
    • A missing test-results or iteration file gives empty sub-results. Runs without evaluation results now appear with no pass/fail result instead of breaking the page.
  • Routes:
    • Removed the error-text matching.
    • InvalidRunIdError now returns 404.
    • A new jsonErrorHandler on app.onError returns { error } JSON for anything unexpected.
  • Client:
    • A new fetchJson helper checks the status and falls back to the status text for bodies that aren't JSON. All seven pages use it.
    • The Analytics page now has an empty state.
  • Docs: updated docs/web.md error handling and added a missing-parquet section to docs/data.md.

Known limits (documented in docs/data.md)

  • A partial write that leaves test-run.parquet without test-config.parquet reads as "no data", not as an error.
  • The first write of each parquet file isn't atomic. An interrupted first write can leave a corrupt file that still returns a (now JSON) 500. This predates this PR.

Testing

  • New integration tests run every query against a missing data directory, an empty one, and each partial file set. All 20 of them fail on main and pass here.
  • New unit tests cover fetchJson, jsonErrorHandler, and the invalid-run-ID 404s.
  • make test: 1057 passing.
  • Ran the built skillwalker-web against a data directory that doesn't exist. All list endpoints return 200 with empty JSON, and the detail endpoints return a JSON 404, both for unknown and for malformed run IDs.

🤖 Generated with Claude Code

mxriverlynn and others added 5 commits September 22, 2026 13:48
Queries read parquet files with DuckDB unconditionally, so a missing data
directory, an empty one, or a partial set of files threw
'IO Error: No files found that match the pattern' and every web page
returned 500.

List queries now return [] when their files are missing, detail queries
report 'run not found', and a missing test-results or iteration file
yields empty sub-results instead of an error.

Co-Authored-By: Claude <noreply@anthropic.com>
Remove the 'No such file or directory' matching from the SCIL/ACIL
routes; the data layer now returns empty results for missing files.
Detail routes map InvalidRunIdError to 404, and an onError handler
replaces Hono's plain-text 500 with a JSON body the client can parse.

Co-Authored-By: Claude <noreply@anthropic.com>
Add a shared fetchJson helper that checks the response status and falls
back to the status text when an error body is not JSON, and use it on
all seven pages. The Analytics page now shows an empty-state message
instead of zeroed stats when there are no test results.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@mxriverlynn
mxriverlynn marked this pull request as ready for review September 22, 2026 19:55
@mxriverlynn
mxriverlynn merged commit 5d9326c into main Sep 22, 2026
7 checks passed
@mxriverlynn
mxriverlynn deleted the fix/web-no-data branch September 22, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant