Null Analysis ID Generation Breaking Analysis Links

← All Specs

Goal

Fix /analysis/None being generated in hypothesis pages when a hypothesis has a NULL analysis_id in the database.

Acceptance Criteria

☑ /hypothesis/{id} pages with NULL analysis_id do not contain /analysis/None links
☑ Source Analysis section handles missing analysis_id gracefully
☑ Page cache cleared for stale entries

Root Cause

Two issues:

  • h.get('analysis_id', '') returns None (not '') when the key exists in the dict but value is None — Python dict.get() only uses the default when key is missing
  • Stale page_cache entries contained the old HTML with /analysis/None
  • Fix Applied

    Main api.py already had a fix using source_analysis_url variable:

    analysis_id = (h.get("analysis_id") or "").strip()
    source_analysis_url = f"/analysis/{html.escape(analysis_id)}" if analysis_id else ""

    But the page cache still served old HTML with /analysis/None. Cleared hypothesis page cache.

    Work Log

    2026-04-04 12:42 UTC — Slot 4

    • Verified /analysis/None → 301 → /analyses/None → 404 (broken)
    • Found root cause: stale page cache with old HTML containing /analysis/None
    • Cleared hypothesis page cache: DELETE FROM page_cache WHERE cache_key LIKE 'hypothesis:%'
    • Tested h-de0d4364 (null analysis_id): /analysis/None no longer present
    • Result: Done — cache cleared, bug resolved

    Tasks using this spec (1)
    Null Analysis ID Generation Breaking Analysis Links
    done P70
    File: f7fa8abf_5fe0_null_analysis_id_spec.md
    Modified: 2026-05-01 20:13
    Size: 1.5 KB