ReviewOS

stacks/wildloop

A trail that does not exist answers 200, with its not-found state hidden

#1014
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

/trail/999999999 answers HTTP 200, and both of the page's headings are served x-cloaked — so a crawler is told the request succeeded and then shown nothing. Fetched from the QA app:

http status: 200
CLOAKED  
CLOAKED  Trail not found

The not-found markup is in the document, but x-cloak is display: none !important until hydration, so it is absent from the accessibility tree of the served page. The literal is served too, unresolved.

This is the one acceptance criterion from #1012 that was not met. It is split out rather than left inside that issue because it is a different piece of work: #1012 was about a page serving no identity, which is fixed on all seven detail pages.

Why it was left

Deliberately, not by oversight. trail/[id].stx sets ssrTrail = null for both "no row with that id" and "the lookup threw", and those want opposite handling: a missing trail should render its not-found state, while a failed lookup should keep the client's branch intact so a page that can still load is not replaced by a denial. With one value standing for both, serving both branches was the safe choice, and the page carries noindex either way so nothing is indexed wrongly.

What it needs

  • A flag separating the two, so the server knows which case it is in:

    let ssrTrailLookupFailed = false
    try { ssrTrail = (await Trail.find(id)) ?? null }
    catch { ssrTrail = null; ssrTrailLookupFailed = true }
  • With a resolved absence, serve the not-found card uncloaked and suppress the main branch's heading — the @if/