Fix inline-JS parse errors across wiki, listings, landscape, mission, gap pages

← All Specs

Fix inline-JS parse errors across wiki, listings, landscape, mission, gap pages

Task ID: audit-js-fixes-2026-05-14 Layer: Atlas (UI / page-render JS) Date: 2026-05-14 v1 carve-out: user-authorized; v1 still serves scidex.ai

Problem

The 2026-05-13 site audit (1,451 page fetches across 4 parallel agents)
found 5 inline-JS parse error clusters affecting every wiki page (~18K
rows), the two top-level listings, and the discuss/retry buttons on
landscape and mission pages.

Root cause shared with the artifact-tab fix (PR #1383): Python f"""…""" literals collapse \' to bare '. When that bare quote
lands inside an outer single-quoted JS string, the string closes early
and the rest of the line is a syntax error. Chrome aborts parsing of
the whole <script> tag — so subsequent functions defined in the same
block are never created.

There is a separate sub-cluster on plain triple-quoted strings
where {{ group: "scidex" }} was written as if the surrounding
string were an f-string. In a plain string Python preserves the
double braces, so the browser sees ({{ → JS SyntaxError.

Fix

Seven \'\\' replacements in f-string contexts, and one {{...}}{...} replacement in a plain triple-quoted block:

linefunction / routefix
api.py:11521landscape_discuss_page retry buttoncurrentCursor=\'\'\\'\\
api.py:48124mission_discuss_page retryfetchDiscussions(\'\\'
api.py:49704/hypotheses/ listing live-search retrydispatchEvent(new Event(\'input\'))\\'
api.py:55447/experiments/ listing live-search retrysame
api.py:80640-80642wiki comments reaction buttons (3 lines)reactWikiComment(\'\\'
api.py:73393gap_detail_page hypothes.is config (plain triple-quoted){{{, }}} on three adjacent lines
The entity-page hypothes.is block at api.py:78396 already renders
correctly because its enclosing string IS an f-string — {{...}}
collapses to {...} in the rendered HTML. No change at that
site.

Verification

Pre-deploy:

  • python3 -c "import ast; ast.parse(open('api.py').read())" → OK
  • /tmp/audit-2026-05-13/reverify.py is the regression harness — runs
24 checks and confirms each fix flipped from FAIL → PASS without
regressing previously-PASS checks.

Post-deploy:

  • Re-run the audit harness against scidex.ai.
  • Spot-check 5 representative URLs with node -c on the inline JS:
/wiki/<slug>, /hypotheses/, /experiments/, /landscape/<d>/discuss,
/gap/<id>.
  • Restart scidex-api.

Risk

Very low. The \\' pattern is the established correct idiom at api.py:38850, 38878-80 and PRs #1383, #1403. The two
plain-triple-quoted hypothes.is blocks now produce identical JS to
the three other f-string-enclosed ones already on main.

File: audit-js-fixes-2026-05-14_spec.md
Modified: 2026-05-18 04:17
Size: 2.8 KB