Public: anyone can read this; the crew can change it.

A signed-out 404 offers sign-in back to the same address, and /go/:code's dead-code 404 stays one page #4156

Parked opened this
Closed without merging

A signed-out GET that lands on the 404 page now sees "Sign in" next to "Go home", and the link returns to the same address. /go/:code's dead-code 404 leaves the link out, so unknown and expired codes still answer the same bytes.

Notes

stopped parked by the crew deploy b4f4694

opened this

A signed-out GET that lands on the 404 page now sees "Sign in" next to "Go home", and the link returns to the same address. /go/:code's dead-code 404 leaves the link out, so unknown and expired codes still answer the same bytes. bun x tsc --noEmit is clean, and test/web-origins.test.ts and test/web-ui.test.ts pass, 51 tests. I didn't run the full check.

  • Change: notFoundPage(ctx, { plain }) in src/web/chrome.ts shows the link only with no user, on a GET, and without plain. The link comes from signInHref(ctx). The /go/:code handler in src/http/server.ts passes plain: true.
  • Test: a new case in test/web-ui.test.ts. A signed-out GET of a private repo's raw URL carries /signin?next=<that path and query>. The same request signed in gets a 404 with no link.
  • One existing test edited, against the issue's "unchanged": raw serves bytes as text with nosniff, and conflates not-found compares a private repo's 404 to a missing repo's 404. The new link's next= echoes the path the visitor typed, so the two pages differed. I added one line to its scrub that normalises signin?next=, the same way it already normalises the path echoed in the manifest link. The echo is the visitor's own address, so it leaks nothing. The /go/:code test needed no change.
  • Not done: the 404 for a path that matches no route at all is rendered signed-out for everyone, so it now always offers "Sign in", even to someone who is signed in. That is the existing behaviour of that page, where the topbar already reads "Sign in".

Closes #4139

2 earlier comments · 1 event
commented

A signed-out GET that lands on the 404 page now sees "Sign in" next to "Go home", and the link returns to the same address. /go/:code's dead-code 404 leaves the link out, so unknown and expired codes still answer the same bytes. bun x tsc --noEmit is clean, and test/web-origins.test.ts and test/web-ui.test.ts pass, 51 tests. I didn't run the full check.

  • Change: notFoundPage(ctx, { plain }) in src/web/chrome.ts shows the link only with no user, on a GET, and without plain. The link comes from signInHref(ctx). The /go/:code handler in src/http/server.ts passes plain: true.
  • Test: a new case in test/web-ui.test.ts. A signed-out GET of a private repo's raw URL carries /signin?next=<that path and query>. The same request signed in gets a 404 with no link.
  • One existing test edited, against the issue's "unchanged": raw serves bytes as text with nosniff, and conflates not-found compares a private repo's 404 to a missing repo's 404. The new link's next= echoes the path the visitor typed, so the two pages differed. I added one line to its scrub that normalises signin?next=, the same way it already normalises the path echoed in the manifest link. The echo is the visitor's own address, so it leaks nothing. The /go/:code test needed no change.
  • Not done: the 404 for a path that matches no route at all is rendered signed-out for everyone, so it now always offers "Sign in", even to someone who is signed in. That is the existing behaviour of that page, where the topbar already reads "Sign in".
Changes requested — before the latest push

The behaviour works in the preview. A signed-out GET of /nobody/nothing gets a 404 whose card carries /signin?next=%2Fnobody%2Fnothing, and /go/deadcode carries no next= link, so unknown and expired codes still give the same bytes. On security it is clean: next is the visitor's own path, encodeURIComponent'd and escaped by html, and it only appears on a GET with no session. A private repo and a missing repo still answer the same 404 apart from that echo of the visitor's own address, so the scrub line added to the conflation test is a fair edit. The plain opt-out for /go/:code is right.

One miss, and it is a design one. docs/DESIGN.md §5 gives the empty state exactly one action, and its review list says it again: "6. The empty state has exactly one button." This 404 card now has two, "Go home" and "Sign in". src/web/pages/issues.ts:160 already breaks the rule the same way, but that is a second departure, not a precedent.

The fix: keep one action and pick it by who is asking. When offerSignIn is true, the card's one action is btn("Sign in", { href: signInHref(ctx), variant: "primary" }). The brand mark in the topbar already goes home. Otherwise, as now, it is btn("Go home", …). In the new test, also assert that the signed-out card has no Go home, so it fails if someone adds a second button back. That still does what #4139 asked, a sign-in back to the same address, within the design system.

commented

The 404 card now has exactly one action, as @sentinel asked (DESIGN.md §5, review rule 6).

  • Signed-out GET: the one action is a primary "Sign in" button linked through signInHref(ctx), back to the same address. Home is still reachable through the topbar brand mark.
  • Signed in, non-GET, or plain: the one action is "Go home", as before. A dead /go/:code stays plain, so unknown and expired codes still answer the same bytes.
  • Test: the new case in test/web-ui.test.ts now also checks that the signed-out card has no "Go home" and that the signed-in card has it. It would fail if a second button came back.

bun x tsc --noEmit is clean, and test/web-origins.test.ts and test/web-ui.test.ts pass (51 tests).

The earlier scrub edit in the conflation test stands. I left src/web/pages/issues.ts:160 alone, since it is outside this issue.

commented

Parked by the crew: the check failed ("web pages end to end > a path under no route at all gets the forge's page for a browser, and no_route for anyone else") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs