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

The not-found and failed pages have looks at 390 and 1280 px, light and dark #13536

Merged opened this

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

Merged

scout/forge:scout/13519-the-not-found-and-failed-pages-have-look → main 4 commits fork 1 thread · 1 unresolved

  • Merged. scout/13519-the-not-found-and-failed-pages-have-look was merged into main as b6a5c4b.

Review

Sign in to review this change.
5 files changed +28 −4
docs/design/areas/errors.md added +6
@@ -0,0 +1,6 @@
1 # Errors
2
3 The not-found page (`notFoundPage`, 404) and the failed page (`failedPage`, 500) say one plain sentence and offer one
4 action; they add no component class of their own. Each is pictured by `forge.json` `app.looks`, at phone and desktop
5 width, light and dark: `/looks/missing` answers the not-found page and `/looks/failed` (a route that throws on purpose,
6 `src/web/pages/looks_failed.ts`) answers the failed page. The looks service pictures a page whatever its status.
forge.json +1 −1
@@ -4,7 +4,7 @@
44 "api.github.com"
55 ],
66 "app": {
7 "looks": ["/", "/docs", "/explore", "/board", "/notes", "/review", "/releases", "/apps", "/security", "/system", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/settings/grants", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space"],
7 "looks": ["/", "/docs", "/explore", "/board", "/notes", "/review", "/releases", "/apps", "/security", "/system", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/settings/grants", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space", "/looks/missing", "/looks/failed"],
88 "looksAsOwner": ["/", "/board", "/flow", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/settings/grants", "/talk", "/system", "/maintenance", "/resilience", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space"],
99 "run": "bun run src/main.ts",
1010 "install": "",
src/http/server.ts +4
@@ -3236,6 +3236,10 @@ async function answerGet(
32363236 const matched = isApiPath || url.pathname === "/metrics" || url.pathname === "/health"
32373237 ? apiRouter.match(routeMethod, url.pathname)
32383238 : router.match(routeMethod, url.pathname);
3239 // The picture of the failed page (#13519): a fixture, no route, so no sweep of pages meets
3240 // it; /looks/missing is the not-found page's, by being under no route.
3241 if (request.method === "GET" && url.pathname === "/looks/failed")

Low: this is reachable unauthenticated in production and logs an error per hit, so anyone can flood the error log. Consider logging it at debug level or skipping the log for this fixture.

3242 return failure(app, new Error("looks/failed: thrown on purpose, so the failed page has a picture"), request);
32393243 if (!matched) {
32403244 // A path under no route at all is what a mistyped or stale studio
32413245 // URL lands on. A browser gets the forge's own page for it, same as
test/forge-looks.test.ts +15 −2
@@ -155,6 +155,18 @@ test("every listed path answers 200 to an admin", async () => {
155155 for (const p of declared()) expect([p, (await get(p)).status]).toEqual([p, 200]);
156156 });
157157
158 test("the not-found and failed pages each have a look that answers 404 and 500 on purpose (#13519)", async () => {
159 const { looks } = manifest();
160 const missing = await get("/looks/missing");
161 const failed = await fetch(`${servers.url}/looks/failed`, { headers: { accept: "text/html" } });
162 expect(looks).toContain("/looks/missing");
163 expect(looks).toContain("/looks/failed");
164 expect(missing.status).toBe(404);
165 expect(failed.status).toBe(500);
166 expect(await missing.text()).toContain("<h1>");
167 expect(await failed.text()).toContain("Something went wrong");
168 });
169
158170 test("app.looks stays within 32 paths, each once", () => {
159171 const { looks } = manifest();
160172 expect(looks.length).toBeLessThanOrEqual(32);
@@ -179,8 +191,9 @@ test("`/` signed out is its own look at phone and desktop, taken with no session
179191 test("a look below the top level is the preview seed's, taken as the owner", () => {
180192 const { looks, looksAsOwner } = manifest();
181193 for (const p of looks.filter((p) => !isTopLevel(p))) {
182 expect(p.startsWith("/preview-admin/sample") || p === "/settings/crew" || p === "/settings/security/controls" || p === "/settings/grants" || isHelpLook(p)).toBe(true);
183 expect(looksAsOwner).toContain(p);
194 expect(p.startsWith("/preview-admin/sample") || p === "/settings/crew" || p === "/settings/security/controls" || p === "/settings/grants" || p === "/looks/missing" || p === "/looks/failed" || isHelpLook(p)).toBe(true);
195 // the not-found and failed pages are the same page to everyone: no owner needed
196 if (!p.startsWith("/looks/")) expect(looksAsOwner).toContain(p);
184197 }
185198 });
186199
test/refresh-meta.test.ts +2 −1
@@ -43,7 +43,8 @@ describe("no page refreshes itself", () => {
4343 for (const headers of [{ cookie }, {}]) {
4444 const res = await fetch(`${servers.url}${path}`, { headers, redirect: "manual" });
4545 const body = await res.text();
46 expect(res.status).toBeLessThan(500);
46 // /looks/failed answers 500 on purpose: it is the failed page's picture (#13519)
47 if (path !== "/looks/failed") expect(res.status).toBeLessThan(500);
4748 expect(body).not.toMatch(/http-equiv=["']?refresh/i);
4849 }
4950 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs