Repository navigation
fix(router): harden redirects, store errors, manifest items and config ids - #232
Conversation
…g ids A batch of small router and manifest hardening items: - A version's external redirect destination may no longer sit under the router's own base paths, which the router serves again and so loops on. - serveArchive refuses root objects whose name starts with an underscore (the publisher's and build's bookkeeping files), also with no base path. - A client error from the store for a malformed path is a plain 404 instead of a 503 and a logged error; credential, timeout and rate limit refusals stay failures. - A tag's releaseUrl is pinned to github.com and the banner bases to coder.com. - The release schedule is validated before it is served or cached. - The Global Config id must look like ecfg_ plus alphanumerics before it is placed in an API path. - The reader skips and logs one malformed manifest item instead of failing every request; writers and publishers stay strict. - The router turns off the Next image optimizer, and sharp and source-map-js move to their patched releases in the lockfile. Assisted-by: AI
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
/coder-agents-review |
DOCS-1351 Clear the pre-public batch: fake AWS key, internal identifiers, flip-day checklist and hardening items
Low/Info batch. https://github.com/coder/security-assessments/issues/386 Before the repository goes public (§A):
Hardening, after the flip:
Split into separate issues as work starts. |
Jesswinters
left a comment
There was a problem hiding this comment.
Not approving yet: there is one blocker, inline at reader.ts:55. Skipping a malformed item now counts as a successful refresh, so the bad entry also disappears on warm isolates instead of them serving the last good snapshot. If that item is the mainline line, the whole root site 404s.
The external redirect checks are thorough. //, /\, %2F%2F, %5C, tab, newline, userinfo, look-alike hosts, dot segments, javascript:, data:, scheme-relative URLs and Cyrillic letters are all refused. The check runs at publish, at read and at response time, and every refusal ends in a 404, never a 500. The config id check runs on both read and write and doesn't echo the value. The store error message carries only the status, never the token, and the bookkeeping guard leaves _next/ and _not-found/ alone.
Beyond the blocker there are three things I'd fix. The new 4xx handling is a denylist, so an unexpected 4xx such as 400, 402 or 410 becomes a silent 404 that the edge caches. A percent-encoded underscore gets past the new bookkeeping guard. And the releaseUrl refine throws from safeParse on a value that isn't a URL.
Checks I ran on f5810c5: router 136 of 136 and docs-manifest 121 of 121, typecheck clean for both, and oxlint and oxfmt clean. The new tests fail on main, except the three guards. This head merges cleanly with #228, and on the merged tree router 139 of 139 and docs-manifest 123 of 123 pass. CI is green.
pnpm-lock.yaml: the bumps fit the existing ranges (next@16.3.8 allows sharp ^0.35.4). Please name the sharp advisories in the body: below 0.35.5 it bundles a vulnerable librsvg (GHSA-wq5f-xc86-pv6w), and below 0.35.4 a vulnerable libheif (GHSA-rgj7-g3m4-5g8c). The source-map-js 1.2.2 bump isn't explained and looks unrelated, so either justify it or drop it.
Generated by Coder Agents on behalf of @Jesswinters.
| const items = await options.getAll(); | ||
| const fresh = { manifest: parseManifestItems(items), fetchedAt: now() }; | ||
| const fresh = { | ||
| manifest: parseManifestItems(items, { onInvalidItem: options.onInvalidItem }), |
There was a problem hiding this comment.
Blocking: before this change, a malformed item made refresh() throw. A warm isolate then called onError and kept serving the last good snapshot, as the reader's doc comment promises ("degrades to stale routing, never to a site-wide 404"). Now the item is skipped, the refresh succeeds, snapshot is overwritten and onError never fires. Within 60 s every warm isolate drops that entry too.
The worst case is the mainline line, or the mainline key itself. manifest.mainline then names a line that no longer exists, resolveRoute returns null for every unprefixed path, / shows the placeholder, and everything else is a 404 with s-maxage=60, stale-while-revalidate=300. A scratch reader test showed it: the first read had lines [2.37, 2.36] with mainline 2.37. After a refresh where line_2-37 had a bad sha, the lines were [2.36], mainline was still 2.37, and onError was called 0 times.
Suggested fix: fall back per key. When an item fails, keep the previous snapshot's value for that key, and skip it only when there is none (a cold start). At a minimum, treat a failure of mainline or of the mainline line as a failed refresh. Please add a test for a warm reader with a bad mainline item that still serves the old mainline.
There was a problem hiding this comment.
Fixed in 6ccc831. The reader now passes its last good manifest to parseManifestItems as previous, so a malformed item keeps its value from there. It is dropped only when there isn't one, which means a cold start or a key that's new since the last good read. If that leaves mainline or the line it names unservable, the parse throws. A warm reader then keeps its whole snapshot and calls onError, and a cold reader rejects, so the router answers its uncached 503 instead of 404-ing the root.
Tests in reader.test.ts: a warm reader whose mainline line goes bad keeps the old 2.37 item and mainline. A warm reader whose mainline value goes bad keeps 2.37. A warm reader still picks up good changes alongside a bad item. A cold reader skips a bad non-mainline line. A cold reader rejects when the mainline or its line is bad. The first three and the last one fail on f5810c5.
| timedOut, | ||
| ]); | ||
| } catch (error) { | ||
| if (isStoreClientError(error)) return null; |
There was a problem hiding this comment.
Should fix: ROUTER_SIDE_STATUSES (line 34) is a denylist, so every other 4xx is now a silent miss. That includes 400 from a malformed token or an API change, 402 for billing, 410 and 451. A miss falls through to the not-found page, which the edge caches. Before, these were a 503 with no-store and a log line. In a scratch handler test, a store throwing Failed to fetch blob: 400 Bad Request on every key gave a 404 with s-maxage=60, stale-while-revalidate=300 and no console.error.
The same applies to _redirects.json: a 4xx there becomes absent, probeFailed is never set, and nothing marks the response no-store. Since If-None-Match is forwarded from the client, a header the client picks could, if the store ever rejects it with a 4xx, turn a real page into a cached 404.
Suggested fix, to fail closed: treat only the path-shaped statuses as misses (400, and maybe 414), mark those responses no-store like probeFailed does, and log them at a low rate rather than not at all. This also keeps #228's "store failure means no-store" contract intact once both land.
There was a problem hiding this comment.
Fixed in b545378, and switched to an allowlist. Only 400 and 414 (isStoreKeyRefusal) count as a miss now. The catch moved out of readObject and into the handler's main serveArchive call. That miss is sent no-store and logged at most once a minute. Every other status throws as it did before this PR, which gives a 503 with no-store and a log line.
The redirects read no longer swallows any 4xx. A 400 on _redirects.json now goes through the existing failure path, so it sets probeFailed, the response is no-store, and the error is logged. That keeps #228's contract that a store failure means no-store. Since a client-chosen If-None-Match can only produce an uncached miss, it can't pin a 404.
Tests in archive-handler.test.ts: 400 and 414 give a 404 with no-store, logged once and then again after 60 s. 401, 402, 403, 408, 410, 429 and 451 give a 503 with no-store. A 400 on _redirects.json gives a no-store 404 and logs. All three fail on f5810c5.
| if (prefix !== "" && !mapped.key.startsWith(`${prefix}/`)) return null; | ||
| // The publisher's and build's own bookkeeping objects sit at the prefix root. | ||
| const relativeKey = prefix === "" ? mapped.key : mapped.key.slice(prefix.length + 1); | ||
| if (relativeKey.startsWith("_") && !relativeKey.includes("/")) return null; |
There was a problem hiding this comment.
Should fix: this guard checks the raw key, so /%5Fobjects.json and /%5fobjects.json get past it. hasUnsafePathSegment only rejects an encoded dot, slash or backslash, and the SDK builds https://<store>/<prefix>/%5Fobjects.json without re-encoding. With a getter that decodes like an object store, /_objects.json got a 404 but both encoded forms got a 200 with the object body.
I didn't verify whether Vercel Blob or Vercel's edge decodes %5F. The PR's own reasoning (an encoded NUL makes the store answer 4xx) suggests the store does decode. This only affects deployments with an empty base path, but the body says the change "closes it".
Suggested fix: check the decoded relative key and refuse when it can't be decoded, then add the %5F and %5f cases to the test.
There was a problem hiding this comment.
Fixed in b545378. The guard now checks the percent-decoded relative key, and it refuses a key that doesn't decode. The test in archive.test.ts covers /%5Fobjects.json, /%5fobjects.json and an undecodable /%E0%A4%A.json, and asserts that the getter is never called for any of them. _next/static/ is still served. The test fails on f5810c5.
| releaseUrl: z.url({ protocol: /^https$/ }).optional(), | ||
| releaseUrl: z | ||
| .url({ protocol: /^https$/ }) | ||
| .refine((value) => isPlainHost(value, "github.com"), "releaseUrl must be on github.com") |
There was a problem hiding this comment.
Should fix: in Zod 4, refinements still run after z.url() fails, so new URL throws inside this refine. tagItemSchema.safeParse({ ...tag, releaseUrl: "not a url" }) throws Invalid URL. A strict parseManifestItems then fails with a TypeError instead of a ManifestParseError naming the key, which is what cli.ts promises operators. The reader is fine only because the new try/catch swallows it. Have isPlainHost (line 57) return false when URL.canParse(value) is false. The existing deploymentUrl refine at line 49 has the same problem with deployment: "not a url", so add an unparseable-URL case for both.
There was a problem hiding this comment.
Fixed in 6ccc831. isPlainHost now lives in a new import-free safe-urls.ts and returns false when URL.canParse fails. The deploymentUrl refine got the same guard. The test in items.test.ts checks that tagItemSchema.safeParse with releaseUrl: "not a url" and with deployment: "not a url" returns a failure. It also checks that strict parseManifestItems throws a ManifestParseError naming tag_2-36-4 for both. The test fails on f5810c5 with the TypeError.
| return ( | ||
| url.protocol === "https:" && | ||
| url.hostname.length > 0 && | ||
| isPlainHost(value, "coder.com") && |
There was a problem hiding this comment.
Should fix: pinning the banner host to coder.com breaks the parity that the comment above this schema (lines 120 to 122) promises with isSafeLegacyBase in @coder/docs-ui. beta-banner.tsx (around lines 118 to 121) still says it pins "never the host". Export one host-pin helper and use it in both places, as AGENTS.md asks, or update both comments and say why the client check is looser.
There was a problem hiding this comment.
Fixed in 6ccc831 with one shared helper. isSafeBannerBase in @coder/docs-manifest/safe-urls, a new zod-free subpath export, is the schema's refine. isSafeLegacyBase in beta-banner.tsx is now that same function, so the server and the client judge the same string with the same check, coder.com pin included. The comment about the client pinning "never the host" is gone. beta-banner.test.tsx adds look-alike, foreign-host and userinfo cases.
| * `manifest.banner` undefined instead of failing the parse. | ||
| */ | ||
| export function parseManifestItems(items: Record<string, unknown>): Manifest { | ||
| export function parseManifestItems( |
There was a problem hiding this comment.
Nit: the docstring just above (lines 213 to 220) still says a malformed known key "fails loudly rather than silently dropping a version". With onInvalidItem that's no longer true for readers, so it should say so. Separately, isPlainHost accepts https://github.com:443/... and https://Coder.com/docs because URL normalises them while the raw value is what gets served. That's harmless, but "no port" in its comment isn't literally true.
There was a problem hiding this comment.
Both fixed in 6ccc831. The docstring now describes both modes: strict by default, and with onInvalidItem the item is reported and keeps its last good value, or is dropped, with the parse still throwing if the mainline becomes unservable. isPlainHost now compares the raw string against https://<host>/ as well as parsing it, so https://github.com:443/... and https://Coder.com/docs are refused. That makes "no port" literally true. Both cases are in items.test.ts.
| if (!EXTERNAL_PREFIXES.some((prefix) => url.startsWith(prefix))) { | ||
| return `external destination must start with ${EXTERNAL_PREFIXES.join(" or ")}`; | ||
| } | ||
| const path = url.slice(url.indexOf("/", "https://".length)).toLowerCase(); |
There was a problem hiding this comment.
Nit: on read, one self-loop rule makes parseVersionRedirectsArtifact throw, so that version loses all of its redirects, not just that rule. It's logged, the version's rules become null and they're checked again after 60 s. That's correct fail-closed behaviour, but worth saying in the PR body. I checked coder/coder release/2.20 through 2.38, and none has an https destination in docs/redirects.json today. https://coder.com/docs. and https://coder.com/docs.html are still accepted, which is harmless unless coder.com normalises them to /docs.
There was a problem hiding this comment.
Agreed, no code change. I've added both points to the PR body: one self-loop rule fails that version's whole artifact closed (logged, rules null, retried after 60 s), and https://coder.com/docs. and .../docs.html are still accepted. Thanks for checking release/2.20 through 2.38.
| } | ||
| }); | ||
|
|
||
| test("the image optimizer is off on a router that serves no images of its own", () => { |
There was a problem hiding this comment.
Nit: this asserts a config value, not behaviour, so it adds little. More generally, the two new test files are named after the PR (router-hardening.test.ts), while their cases belong with the code they cover: archive.test.ts, items.test.ts, write.test.ts and releases-handler.test.ts. 408 is in the denylist but has no test, and the as never casts go against the AGENTS.md rule on casts, even though they follow an existing pattern.
There was a problem hiding this comment.
Fixed in 6ccc831 and b545378. Both router-hardening.test.ts files are gone, and each case now lives with its module: archive.test.ts, archive-handler.test.ts, releases-handler.test.ts, items.test.ts, reader.test.ts, write.test.ts and version-redirects.test.ts. I dropped the images.unoptimized assertion. 408 is now covered, as a 503, in the all-other-statuses test. The new tests add no casts: handlerWith now takes a Getter, the throwing getters are typed as Getter, and the remaining cases reuse each file's existing fakeGet. The test-file-naming rule is now in AGENTS.md (5fb9893).
…f dropping it Skipping a malformed item made the refresh succeed with that item missing, so every warm isolate dropped it within a minute instead of serving the last good snapshot. When the item was the mainline or its line, the whole root site became a cached 404. The reader now passes its last good manifest to the parser, and a malformed item keeps its value from there; it is dropped only on a cold start. If that leaves the mainline or its line unservable, the parse throws, so a warm reader keeps its whole snapshot and a cold one answers the uncached 503. The host pin moves to a dependency-free safe-urls module. It compares the raw string against https://<host>/, so a port, userinfo or case change is refused, and it returns false rather than throwing on a value that is not a URL, so safeParse reports a failure naming the key. The banner component now uses the same check as the schema instead of a looser copy. The tests move into the files for the modules they cover. Assisted-by: AI
…r cache them Any 4xx outside a short denylist became a silent miss, so a 400 from a bad token, a 402 or a 410 turned every page into a 404 the edge cached for a minute, with nothing logged. A 4xx on a version's redirects object also read as "no redirects" without marking the response uncacheable. Now only 400 and 414, the statuses the store gives for a key it cannot take, count as a miss, and that response is sent with no-store and logged at most once a minute. Every other status is a failure again, and the redirects read no longer swallows any of them. The bookkeeping-object guard checks the percent-decoded key, so %5F and %5f spellings are refused too, and a key that does not decode is refused outright. The tests move into the files for the modules they cover, and the test that only asserted a config value is dropped. Assisted-by: AI
The sharp bump is the security fix; source-map-js 1.2.2 came along with the lockfile refresh and has no advisory or need behind it, so it is put back to 1.2.1. Assisted-by: AI
…s and tolerant readers Assisted-by: AI
Brings in the redirects size cap (#228) and the rest of main; the two branches edit different functions in archive.ts and merged without conflict. Assisted-by: AI
Jesswinters
left a comment
There was a problem hiding this comment.
Re-reviewed at 392640b. Approving: the blocker is fixed, every point from my last review is addressed, and I found no new blockers.
Blocker (6ccc831). The reader now passes its last good manifest as previous, so a malformed item keeps its last good value and is dropped only when there isn't one. If the mainline key, or the line it names, would be dropped, the parse throws instead. A warm reader then keeps its whole snapshot and calls onError, and a cold one answers the uncached 503. I traced the cases. A malformed mainline line with a previous value is kept. A new mainline whose line is malformed and missing from the previous snapshot throws, so the old mainline stays. A malformed mainline on a cold start throws.
Should-fix items.
- Store errors (
b545378): only 400 and 414 count as a miss now. That miss is sentno-storeand logged at most once a minute. A 4xx on_redirects.jsonis a store failure again, which keeps the contract from #228, now onmain, that a store failure is never cached. - Bookkeeping guard: it checks the percent-decoded key and refuses a key that doesn't decode. A double-encoded
%255Fdecodes only to%5F, so it stays safe. isPlainHost: it no longer throws, and it now matches the raw string againsthttps://<host>/. A port, userinfo or case change is refused, and the authority can't run past the first/.- Banner check: the schema and the banner component share one
isSafeBannerBase. The liveversions.jsonbanner base,https://coder.com/docs, passes it, so the stricter client check changes nothing in production. - Tests and lockfile: the tests live with their modules,
source-map-jsis no longer bumped, and the AGENTS.md rules record the review outcomes.
Checks I ran on 392640b.
- docs-manifest 134 of 134, router 141 of 141 and docs-ui 173 of 173 tests pass, typecheck is clean for all three, and oxlint and oxfmt are clean on the changed files.
- Fail-first: with
f5810c5'sreader.tsswapped in, the warm-reader test fails, and without the decoded-key check the bookkeeping-object test fails. - The merge of
mainwas clean (no--remerge-diffoutput). The head also merges cleanly with today'smain(#233, #237), and CI is green (26 passed, 1 skipped).
I have two non-blocking suggestions, both inline. One is about what readers see if the store answers 400 to every key. The other is about the edge-cached 404 a cold isolate can give for a dropped non-mainline version.
Generated by Coder Agents on behalf of @Jesswinters.
Generated by Coder Agents on behalf of @Jesswinters.
| try { | ||
| served = await serveArchive(target, request, archiveDeps); | ||
| } catch (error) { | ||
| if (!isStoreKeyRefusal(error)) throw error; |
There was a problem hiding this comment.
Suggestion (non-blocking): as the comment below says, a broken token can also get a 400. If the store ever answers 400 to every key, every page is now an uncached 404 logged once a minute. Before, it was a 503. Neither is cached, but a crawler treats a 404 as "this page is gone" and a 503 as "come back later", so a site-wide token problem would now look like the whole site disappearing.
One way to keep both: refuse the keys the store is known to reject before the request, for example a decoded key containing a control character or a key over the store's length limit, as decodedKey already does for undecodable keys. Then treat a 400 or 414 from the store as a failure again (503). If that's more than you want here, consider at least logging the keyed path's shape, not only the error, so the once-a-minute log line separates "one hostile key" from "every key".
There was a problem hiding this comment.
Done in 4dc10d9, with your first option. serveArchive now refuses, before any store call, a decoded key that contains a control character (U+0000 to U+001F, U+007F) or that is longer than 950 characters. 950 is @vercel/blob's MAXIMUM_PATHNAME_LENGTH; the SDK doesn't export it, so no stored key can be longer. These refusals use the same 404 path as an undecodable key. A 400 or 414 from the store is now a failure again: a 503 with no-store. It's still logged at most once a minute, and the line now carries the path's shape (length, segment count, number of percent-escapes) instead of only the error, so one hostile key can be told apart from every key failing.
Tests: in archive.test.ts, %00, %0A, %1F, %7F and a 951-character key are refused with no store call, and a 950-character key is still requested. In archive-handler.test.ts, a store 400 or 414 on an ordinary key gives a 503 with no-store, logged once and then again after 60 s; the line includes the shape and not the path. Both failed on 392640b. The AGENTS.md rule now says to refuse known-bad input up front and treat the upstream's error statuses as failures (adb6db4).
| } catch (error) { | ||
| if (!options.onInvalidItem) throw error; | ||
| options.onInvalidItem(key, error); | ||
| if (!options.previous || !keepPrevious(manifest, options.previous, key)) dropped.add(key); |
There was a problem hiding this comment.
Optional: on a cold isolate, a malformed non-mainline line has no previous value, so it's dropped. Requests for that version then get the mainline's not-found page with the normal s-maxage=60, stale-while-revalidate=300, while warm isolates still serve the version from their last good copy. So the edge can cache a 404 for a version that is still live, and readers see it come and go depending on which isolate answers.
That's far better than the old whole-site 503, so this doesn't block. If you want to close it, the parse could report the keys it dropped (for example manifest.degraded: Set<string>). The handler could then send no-store for a path whose version key was dropped, just as it does for probeFailed and keyRefused.
There was a problem hiding this comment.
Done in e92d6ab and 4dc10d9. Manifest has a new degraded: Set<string> holding the keys a lenient parse dropped because it had no last good value to keep. It's always empty after a strict parse or a warm refresh that kept the previous value. namesDegradedVersion(pathname, manifest, { basePath }) in route.ts says whether a path is under one of those versions, matching either the canonical segment or the old @<id> form through a new segmentNamesVersion in version-segment.ts. The handler sends no-store on that miss.
Tests: items.test.ts checks the dropped keys on a cold parse, and that the set is empty on a warm or strict parse. route.test.ts covers line, tag and dev paths with and without a base path. archive-handler.test.ts uses a cold reader with a malformed 2.36: /@2.36/admin/ gets a no-store 404, while an unknown version and the mainline keep s-maxage=60. The handler test failed on 392640b.
A cold isolate drops a malformed item it has no last good value for, while warm isolates keep serving that version from their snapshot. The router could not tell such a miss from a version that never existed, so the edge cached a 404 for a version that is still live elsewhere. The parse now records those keys in manifest.degraded, and namesDegradedVersion says whether a path is under one of them, so the router can keep that miss out of the cache. Assisted-by: AI
… and 414 failures Treating a store 400 or 414 as a miss meant a broken token, which also gets a 400, would turn every page into a 404, and crawlers read that as the whole site being gone. Keys the store is known to reject are now refused before any call: a decoded key with a control character, or one over the store's 950-character pathname limit. A 400 or 414 from the store is a 503 again. It is logged once a minute with the key's shape (length, segments, percent-escapes) rather than the key, so the log can tell one hostile key from every key failing. A miss for a version this isolate dropped as malformed is now sent with no-store, since other isolates may still serve that version. Assisted-by: AI
…rrors to misses Assisted-by: AI
Merge order
Independent of the redirects size-cap PR (#228); either can land first. Both edit
apps/router/lib/archive.tsin different functions and merge cleanly.Summary
Router and manifest items from the router and publish-pipeline section of the pre-public hardening batch (coder/security-assessments#386, section D). Each is small; none changes behaviour for a well-formed deployment.
Fix
/docsor/beta-docsor under either, since the router serves those paths again. Othercoder.comandgithub.com/coder/destinations still work. The current corpus has no external destinations (docs/redirects.jsononrelease/2.20through2.38has none). On read, one self-loop rule makesparseVersionRedirectsArtifactthrow, so that version loses all of its redirects rather than just that rule: the failure is logged, the rules are null and they are checked again after 60 s, which is the intended fail-closed behaviour.https://coder.com/docs.andhttps://coder.com/docs.htmlare still accepted; that is harmless unless coder.com starts normalising them to/docs.serveArchivereturns a miss for any object directly under the version prefix whose name starts with an underscore (_publish.json,_objects.json,_redirects.json). It checks the percent-decoded key, so%5Fand%5fspellings are refused too, and it refuses a key that does not decode._next/and_not-found/are directories and are unaffected. Under the production base path this was already unreachable; this closes it for an empty base path.@vercel/blob'sMAXIMUM_PATHNAME_LENGTH). Every status the store returns, 400 and 414 included, is a failure: a 503 withno-store. That way a broken token, which also gets a 400, reads as "come back later" to a crawler, not "gone". A 400 or 414 is logged at most once a minute, with the path's shape (length, segments, percent-escapes) rather than the path itself. A 4xx on_redirects.jsonis a failure, not "no redirects". The store SDK reports the status only in the error message, so it is read from there.releaseUrlmust be ongithub.comand the banner's two bases oncoder.com, spelled exactly (https://<host>/, so no userinfo, port or case change). The check lives in a new zod-free@coder/docs-manifest/safe-urlsmodule. The banner component uses the sameisSafeBannerBaseas the schema rather than a looser copy, and a value that is not a URL is a parse failure naming the key, not aTypeError./releases.jsonvalidates the schedule withparseReleaseSchedulebefore it is cached or served; a schedule that fails keeps the last good copy, or answers a 503 that is never cached.readManifestItemsandwriteManifestItemsrefuse aconfigIdthat is notecfg_plus alphanumerics before it reaches the API path.parseManifestItemstakes an optionalonInvalidItemandprevious. The router's reader passes both, so one malformed line, tag or other item is logged and keeps its value from the last good snapshot while the rest still route. It is dropped only when there is no previous value (a cold start, or a key that is new since the last good read). If that leaves the mainline or its line unservable, the parse throws: a warm reader keeps its whole last good snapshot, and a cold one answers the uncached 503 rather than 404-ing the root. The dropped keys are reported inmanifest.degraded, and the router sendsno-storeon a miss under such a version, since other isolates may still serve it. WithoutonInvalidItemthe parser still throws, so publishers and writers stay strict.images.unoptimized: truein the router's Next config; the app serves only route handlers.sharpto 0.35.5, with its libvips packages, withinnext@16.3.8's^0.35.4range. Below 0.35.5, sharp bundles a vulnerable librsvg (GHSA-wq5f-xc86-pv6w), and below 0.35.4 a vulnerable libheif (GHSA-rgj7-g3m4-5g8c). Nopackage.jsonchanged. An unrelatedsource-map-jsbump that came along with the lockfile refresh has been dropped.Not included: the loops between static and per-version redirect rules, and the cache-cost levers on
/beta-docs/api/search(Range, query strings). Those need a design decision or a WAF or CDN change rather than a small code fix.QA
There is nothing to see on the site; these are router and manifest behaviours. The new tests sit beside the code they cover, in
apps/router/lib/(archive,archive-handlerandreleases-handlertests) andpackages/docs-manifest/src/(items,reader,writeandversion-redirectstests), pluspackages/docs-ui/src/beta-banner.test.tsx. The checks on this PR run them.Pages to compare
Testing
Each new test was run against the previous code and fails there, except two guards that pin behaviour that must not change (look-alike prefixes stay allowed, and strict parsing without
onInvalidItem). The review-round tests were also run against the first head of this PR and fail there: the warm and cold reader cases, the 4xx allowlist, the%5Fguard, the non-URLsafeParseand the banner host pin. The router (136), docs-manifest (126) and docs-ui (173) suites, the typechecks for those andapps/docs, and oxfmt and oxlint pass locally,pnpm install --frozen-lockfileaccepts the lockfile, and the branch merges cleanly withmainand with #228.Review feedback applied in 6ccc831, b545378, 7f700dc and 5fb9893.
Second-round feedback applied in e92d6ab, 4dc10d9 and adb6db4. Each new test was run against 392640b and fails there. The router (143), docs-manifest (136) and docs-ui (173) suites, their typechecks, and oxfmt and oxlint pass locally.
Upstream
No. All of it is specific to Coder's router and manifest.
Linear: DOCS-1351
🤖 Built with AI assistance.