Skip to content

Clean unpublished-state render when /api/dataset/<id>/{readme,tree} has no published version #28

Closed

Description

@neuromechanist

Symptom

Visiting https://ww2.nemar.org/dataset/on005506 (and on005507, plus the others in the original #529 cohort) hangs ~5–8 seconds, then renders with empty content. Network tab shows:

  • /api/dataset/on005506/readme?v=v1.0.0 → HTTP 500 after ~5s (timeout)
  • /api/dataset/on005506/tree?v=v1.0.0 → 200 with "no manifest" fallback HTML

When the browser retries 500 responses (or when multiple cards load similar pages back-to-back), the per-IP rate limit at the CF edge starts returning 429 to subsequent requests, making the experience even worse on retry.

Root cause: these datasets have latest_version_doi: null and versions: [] on data.nemar.org/<id>/ — they were never published. The current endpoint code path tries to fetch the manifest regardless, hits a 4s timeout, returns 500.

Verified state for on005506:

$ curl -s https://api.nemar.org/datasets/on005506 | jq '.dataset | {latest_version_doi, github_repo, status}'
{ "latest_version_doi": null, "github_repo": "nemarDatasets/on005506", "status": "active" }
$ curl -s https://data.nemar.org/on005506/
{ "dataset_id": "on005506", "latest": null, "versions": [] }
$ curl -s -w "%{http_code} %{time_total}s" https://ww2.nemar.org/api/dataset/on005506/readme?v=v1.0.0
500 5.16s

Fix

In src/pages/api/dataset/[id]/readme.ts and src/pages/api/dataset/[id]/tree.ts:

  1. Before calling getManifest, call getDatasetTopLevel(id) (or whatever exposes versions: [] / latest: null). If no versions exist, return a clean 200 with an "unpublished" HTML state immediately — no 5s timeout, no 500.
  2. The unpublished HTML can say something like "This dataset has been onboarded but not yet published. Check back later or contact the dataset owner."
  3. Same on the main /dataset/[id] SSR path: detect unpublished early and render the unpublished state instead of waiting for the deferred client-side fetches to error out.

Also reasonable: have these endpoints honor Cache-Control: public, max-age=300 even on the unpublished branch, so the CF cache serves the cheap response on retry instead of forcing the worker to re-evaluate.

Acceptance

  • /api/dataset/on005506/readme?v=v1.0.0 returns 200 in < 500ms (no manifest fetch attempted)
  • /api/dataset/on005506/tree?v=v1.0.0 same
  • /dataset/on005506 renders an unpublished state, no spinner stuck for 5s
  • No more 500-driven retry storms that cascade into 429s

Notes

  • This is independent of the underlying AI Mode search: the on-state ring and placeholder show before, or without, the widget #529 root-cause fix (recover the missing version rows / publish flow). This issue is purely about the website rendering a graceful state for the not-yet-published case.
  • Related on the data side: a separate website issue (filed alongside this one) covers introducing a compact summary.json artifact so even published datasets stop pulling 10 MB manifests for path-only views.

Activity

  1. added
    bug
    on May 19, 2026
  2. added a commit that references this issue on May 19, 2026
    624202f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions