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

A page that is not found or not yours says where you are and offers home, search and sign-in-and-come-back #12336

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The 404 page now says what was asked for and always offers Search. Home, Sign in and the identical wording for missing and private repos were already there. Pushed.

Notes

shipped production is serving it deploy 5bb6da3

opened this

The 404 page now says what was asked for and always offers Search. Home, Sign in and the identical wording for missing and private repos were already there. Pushed.

What changed

  • In src/web/chrome.ts, notFoundPage now echoes "You asked for <path>". The path is decoded, capped at 120 characters and escaped.
  • Search is now always offered. It goes to /search?q=… when there is a last path segment to search for, and to /search when there isn't.
  • Already on main and left alone: Go home and Explore, and for signed-out visitors Sign in and Create an account with the asked path carried as next=. I kept the existing signInHref, which also handles the platform-edge sign-in, instead of switching to returnTo() from src/web/return_to.ts.
  • test/not-found-way-on.test.ts is new. Signed out, a private repo path and a missing path both return 404 with bodies that are equal once the echoed path is replaced.
  • It also checks that Home, Search and the sign-in link with next=%2Falice%2Fsecret are present.
  • It also checks that a <script> path is escaped and a 500-character path is capped in the echo.

What I didn't do

  • I did not move the page into src/web/pages/not-found.ts. It stays in chrome.ts, which already holds the one 404 for the whole product, so splitting it would only add churn.
  • The sign-in link still carries the full-length path in next=, as before. Only the on-page echo is capped.

How to try it

  • Open /<anyone>/<private-or-missing> signed out.
  • Run bun test test/not-found-way-on.test.ts. That file and test/not-found-asset.test.ts pass, as does bun scripts/design-lint.ts.
  • test/deadends.test.ts also passed in the same run, but I did not re-run it after fixing my own test.
  • bun x tsc --noEmit printed nothing. scripts/gate.ts and scripts/fast.ts are not in this clone, so I ran neither.
  • A pre-push hook wanted a "Try:" line in a commit message, so there is an empty commit carrying one.

Closes #12323

5 earlier comments · 1 event
commented

The 404 page now says what was asked for and always offers Search. Home, Sign in and the identical wording for missing and private repos were already there. Pushed.

What changed

  • In src/web/chrome.ts, notFoundPage now echoes "You asked for <path>". The path is decoded, capped at 120 characters and escaped.
  • Search is now always offered. It goes to /search?q=… when there is a last path segment to search for, and to /search when there isn't.
  • Already on main and left alone: Go home and Explore, and for signed-out visitors Sign in and Create an account with the asked path carried as next=. I kept the existing signInHref, which also handles the platform-edge sign-in, instead of switching to returnTo() from src/web/return_to.ts.
  • test/not-found-way-on.test.ts is new. Signed out, a private repo path and a missing path both return 404 with bodies that are equal once the echoed path is replaced.
  • It also checks that Home, Search and the sign-in link with next=%2Falice%2Fsecret are present.
  • It also checks that a <script> path is escaped and a 500-character path is capped in the echo.

What I didn't do

  • I did not move the page into src/web/pages/not-found.ts. It stays in chrome.ts, which already holds the one 404 for the whole product, so splitting it would only add churn.
  • The sign-in link still carries the full-length path in next=, as before. Only the on-page echo is capped.

How to try it

  • Open /<anyone>/<private-or-missing> signed out.
  • Run bun test test/not-found-way-on.test.ts. That file and test/not-found-asset.test.ts pass, as does bun scripts/design-lint.ts.
  • test/deadends.test.ts also passed in the same run, but I did not re-run it after fixing my own test.
  • bun x tsc --noEmit printed nothing. scripts/gate.ts and scripts/fast.ts are not in this clone, so I ran neither.
  • A pre-push hook wanted a "Try:" line in a commit message, so there is an empty commit carrying one.
commented

The deploy didn't fail. The preview is up and answering, and "no tests declared, none run" is the success summary the forge writes for any app whose forge.json has no app.test. Nothing in my change causes it, and I'm not adding a test declaration because the forge's own gate runs the suite in check.

I checked the running preview directly. /healthz returns 200, and a missing path such as /alice/x renders the new "You asked for <code>/alice/x</code>" line. I changed nothing and pushed nothing this turn.

commented

The check failed on two comment lines in src/web/chrome.ts that ran past 100 columns. I rewrapped both: the one above shownPath and the one on quiet in RepoHeaderOptions. Only comments changed, so no tests were run.

The gate also wanted a "Looks:" line in a commit message. The new commit has Looks: /.

bun scripts/gate.ts and bun x tsc --noEmit are clean locally, and the fix is pushed. I did not run the full check suite here; the forge will run it on this push.

commented

I've fixed the failing tests and pushed. The gate and tsc are clean, and the seven test files I ran locally pass: six that were failing, plus test/not-found-way-on.test.ts. I did not run the full suite; the forge's check will.

The cause was the new "You asked for <path>" line on the 404. Several older tests check that a 404 body never contains the path that was requested. The failing files:

  • boards-doors
  • forges-refused
  • front-milestones-private
  • own-session
  • web-ui
  • contribute-no-forge

I kept the echo and changed those tests. Each now strips the echo line before its leak check. The echo is only the reader's own typed path, escaped, so the checks still cover everything else on the page. These tests were not wrong before this pull; they predate the echo. If the stricter "404 never shows the path" rule is wanted, the alternative is to drop the echo instead.

contribute-no-forge was listed as failing in the check but passed here with no edit, so I left it alone. If it is flaky or only fails under the forge's run, it may fail again.

The commit carries a No look: line, since the page itself is unchanged.

commented

I made no code change this round. All six reds pass when I run them here, so I pushed an empty commit to make the forge re-run the check.

  • Passing locally: I ran test/home-frame.test.ts, test/web-code.test.ts and test/contribute-no-forge.test.ts: 48 tests, all pass. test/looks-owner.test.ts is the other red and I did not run it.
  • Why I read these as load, not the 404 change: the check log shows the slowest shard took 160s against 35s in the previous run. The looks-owner test took 90s. The home-frame test is a timing-budget test and ran for 6.5s. The code-browser tests and contribute-no-forge don't touch the 404.
  • Still open: contribute-no-forge also failed in the previous run and passed locally both times. If the same reds come back on a quiet machine, I'll look at them again.
Changes requested — before the latest push

The 404 works in the preview: same words for missing and private, Home/Search/Sign in with next= present. Changes needed, all in one round:

  1. FIRST: the echo "You asked for <path>" repeats what the page says ("The page you asked for does not exist") and the URL bar already shows (principle 1: nothing explains itself twice). It also forced you to weaken five older leak tests (boards-doors, forges-refused, front-milestones-private, own-session, web-ui), which each now strip the echo before asserting the path is absent. That is the wrong trade: drop the echo and revert those test edits. Issue box 3 says 'apart from the echoed path' only because the issue assumed one; it does not require one.
  2. If you keep any echo, it is hand-rolled markup (<p class=muted><code>) outside the named empty-state component (principles 1, 7); put it inside the empty state's description.
  3. The sign-in door should use returnTo()/withReturn() from src/web/return_to.ts as the issue says, not only signInHref; or show in the pull that signInHref already delegates to it.
  4. Remove the unrelated comment rewrap on RepoHeaderOptions.quiet.
  5. The equality test normalises the last path segment to LAST, which can mask a real difference between the two bodies; compare after replacing only the full path and its encoded form.

Two things to do next after that: a Search button with no query (/search) adds a third button to a page whose primary action is Home; check on a 360px phone that the buttons wrap cleanly. Drop the empty commits from the pull.

commented

Items 1–5 are done and pushed. I did not do the 360px phone check or drop the empty commit.

  • Echo (1, 2): I removed the "You asked for …" line and shownPath, and reverted the test edits that stripped it. boards-doors, forges-refused, front-milestones-private, own-session and web-ui assert as they did before. The 404 test now asserts the echo is absent.
  • Sign-in door (3): signInHref does not delegate to returnTo/withReturn. The 404's Sign in button now uses withReturn("/signin", returnTo(ctx)), so it also drops the return address on paths like /go/:code. Behind a platform edge it still uses signInHref, because the edge is how people sign in there. I wrote this as a small notFoundSignIn helper in src/web/chrome.ts.
  • Comment rewrap (4): the RepoHeaderOptions.quiet comment is back to its original form.
  • Equality test (5): it no longer replaces the last path segment. It replaces the full path, its encoded form, and the "Search for ‘…’" button text and /search?q= link. A reader can only tell the two 404s apart through that button, because it names the last segment.
  • Local checks: the touched test files, deadends and tsc are green.
  • Gate: I pushed once with the gate red, because a comment I'd added was 104 columns wide. The follow-up commit fixes it and the gate is clean.
  • Not done, 360px check: the Search button with no query (/search) is still there, as the first round shipped it. I had no way to look at a 360px phone from this sandbox, so someone should check it on the preview.
  • Not done, empty commit: it is still in the history. I can't force-push, so squash the pull when merging to drop it.
Approved

Earlier asks are met: the echo line is gone, the older tests are restored, the Sign in button goes through returnTo/withReturn (edge sign-in kept behind an edge), and the equality test no longer swallows the last segment. On the preview, /alice/secret signed out returns 404 with Go home, Search for ‘secret’, Sign in (/signin?next=%2Falice%2Fsecret), Create an account and Explore, all as plain links that work without JavaScript. Private and missing read the same. Next, in order: (1) Non-blocking: check the Search-with-no-query button at 360px; the buttons should wrap rather than overflow. (2) Non-blocking: the empty commit is in history, so squash on merge.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs