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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13519-the-not-found-and-failed-pages-have-look → main 4 commits fork 1 thread · 1 unresolved
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 @@ | ||
| 4 | 4 | "api.github.com" |
| 5 | 5 | ], |
| 6 | 6 | "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"], | |
| 8 | 8 | "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"], |
| 9 | 9 | "run": "bun run src/main.ts", |
| 10 | 10 | "install": "", |
src/http/server.ts +4
| @@ -3236,6 +3236,10 @@ async function answerGet( | ||
| 3236 | 3236 | const matched = isApiPath || url.pathname === "/metrics" || url.pathname === "/health" |
| 3237 | 3237 | ? apiRouter.match(routeMethod, url.pathname) |
| 3238 | 3238 | : 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") | |
| 3242 | return failure(app, new Error("looks/failed: thrown on purpose, so the failed page has a picture"), request); | |
| 3239 | 3243 | if (!matched) { |
| 3240 | 3244 | // A path under no route at all is what a mistyped or stale studio |
| 3241 | 3245 | // 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 () => { | ||
| 155 | 155 | for (const p of declared()) expect([p, (await get(p)).status]).toEqual([p, 200]); |
| 156 | 156 | }); |
| 157 | 157 | |
| 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 | ||
| 158 | 170 | test("app.looks stays within 32 paths, each once", () => { |
| 159 | 171 | const { looks } = manifest(); |
| 160 | 172 | expect(looks.length).toBeLessThanOrEqual(32); |
| @@ -179,8 +191,9 @@ test("`/` signed out is its own look at phone and desktop, taken with no session | ||
| 179 | 191 | test("a look below the top level is the preview seed's, taken as the owner", () => { |
| 180 | 192 | const { looks, looksAsOwner } = manifest(); |
| 181 | 193 | 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); | |
| 184 | 197 | } |
| 185 | 198 | }); |
| 186 | 199 |
test/refresh-meta.test.ts +2 −1
| @@ -43,7 +43,8 @@ describe("no page refreshes itself", () => { | ||
| 43 | 43 | for (const headers of [{ cookie }, {}]) { |
| 44 | 44 | const res = await fetch(`${servers.url}${path}`, { headers, redirect: "manual" }); |
| 45 | 45 | 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); | |
| 47 | 48 | expect(body).not.toMatch(/http-equiv=["']?refresh/i); |
| 48 | 49 | } |
| 49 | 50 | }); |
new above
offline
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.