Fix /artifact/hypothesis-h-XXX 404 + harden against legacy type-prefix URLs

← All Specs

Fix /artifact/hypothesis-h-XXX 404 + harden against legacy type-prefix URLs

Task ID: artifact-hyp-prefix-2026-05-13 Layer: Atlas (artifact_detail) Date: 2026-05-13 v1 carve-out: user-authorized; v1 still serves scidex.ai

Symptom

https://scidex.ai/artifact/hypothesis-h-7336d351b0 rendered "Artifact
Not Found" although the hypothesis exists.

Root cause

_hyp_adjacent_panel (api.py:32844) prepended a redundant hypothesis-
prefix to ids pulled directly from the hypotheses table. The hypotheses.id is the canonical bare form (h-7336d351b0) and a
matching artifacts row exists at the bare id — not at hypothesis-h-7336d351b0. The URL had no resolver to recover.

The artifacts table holds both conventions across types
(verified by SELECT artifact_type, prefix_shape, count):

typebareprefixed
hypothesis2,160 (h-…)1,328 (hypothesis-…)
analysis420 (SDA-…)231 (analysis-…)
notebook351 (nb-…)999 (notebook-…)
Every hypotheses row resolves at the bare form (1,080 only-bare +
1,328 also-bare = 2,408 of 2,408). So a single canonical link is
correct — but external bookmarks / cached search results may still
point at the prefixed form.

Fix

api.py:

  • api.py:32844 — drop the hypothesis- prefix from the URL emitted
  • by _hyp_adjacent_panel. All hypothesis rows resolve cleanly at the
    bare id.
  • api.py:34642 (artifact_detail) — when literal lookup fails, try
  • stripping a known artifact-type prefix (hypothesis-, figure-,
    dataset-, model-, analysis-, experiment-, paper-,
    notebook-). Accept the match only if the stripped row's
    artifact_type is in the allowed set for that prefix. This stops
    cross-type confusion (e.g. /artifact/figure-h-XXX cannot
    accidentally resolve to a hypothesis with bare id h-XXX).

    The fallback runs after the literal lookup, so every existing valid
    URL continues to resolve via its current path with no extra DB query.

    Verification

    Against the live DB (no code execution required):

    • /artifact/hypothesis-h-7336d351b0 → literal miss → strip
    hypothesis-h-7336d351b0 is type=hypothesismatch
    • /artifact/hypothesis-29a49684-… → literal match (no fallback)
    • /artifact/figure-h-7336d351b0 → literal miss → strip figure-
    h-7336d351b0 is type=hypothesis{figure, paper_figure}
    reject, stays 404
    • /artifact/h-7336d351b0 and /artifact/hypothesis-h-b8cedff2
    literal match (existing behavior preserved)

    Post-deploy: restart scidex-api, hit /artifact/hypothesis-h-7336d351b0 from a returning-visitor cookie,
    confirm the page renders the hypothesis content.

    File: artifact-hyp-prefix-2026-05-13_spec.md
    Modified: 2026-05-18 04:17
    Size: 2.7 KB