Repository navigation
Conversation
There was a problem hiding this comment.
Superseded by the review of
8c619c4e.
This review, of 4ed123fc
🛑 Significant concerns — 1 BLOCKING: an empty, comment-only or all-invalid _redirects file makes every asset request throw a TypeError. There are also 2 WARNINGs: fields silently dropped when main is omitted, and the README's list of supported Wrangler fields is out of date.
Findings: 1 blocking · 2 warnings · 1 info · 2 suggestions (5 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8475.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Code Quality] An empty, comment-only or all-invalid `_redirects` file leaves the raw text in `configuration.redirects`, so `staticRedirectsMatcher` throws on every request
- **File:** src/workerd/server/assets/assets.js:1345
## WARNING (2)
### [Code Quality] With `assets` and no `main`, Worker-only fields (`vars`, `durable_objects`, `queues`, `workflows`, `triggers.crons`, …) are silently dropped or point at a Worker that doesn't exist
- **File:** src/workerd/server/cli/wrangler.rs:392
### [Documentation] README says any field not listed is an error, but `assets` (with `--experimental`) is now supported and `main` is optional when `assets` is set
- **File:** README.md:115
## INFO (1)
### [Code Quality] `serve()` resolves on the child's `exit` event, which can fire before stderr has been drained, so the stderr assertions may flake
- **File:** src/workerd/server/tests/assets/assets-wrangler-test.mjs:65
## SUGGESTION (2)
### [Security] Dotfiles such as `.git/` and `.env` are served from the assets directory by default; consider adding them to the default ignore list as Wrangler does
- **File:** src/workerd/server/cli/wrangler.rs:610
### [Code Quality] `exists()` assumes the disk service always sends an ETag, but the disk service only sets it when the file's modification time can be read
- **File:** src/workerd/server/assets/assets.js:1310
📋 Code Quality: 🛑 1 blocking · 1 warning · 1 info · 1 suggestion
An empty or invalid _redirects crashes every request. Fields are silently dropped without main. Two smaller robustness notes.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] An empty, comment-only or all-invalid
_redirectsfile leaves the raw text inconfiguration.redirects, sostaticRedirectsMatcherthrows on every request (src/workerd/server/assets/assets.js:1345) - [WARNING] With
assetsand nomain, Worker-only fields (vars,durable_objects,queues,workflows,triggers.crons, …) are silently dropped or point at a Worker that doesn't exist (src/workerd/server/cli/wrangler.rs:392) - [INFO]
serve()resolves on the child'sexitevent, which can fire before stderr has been drained, so the stderr assertions may flake (src/workerd/server/tests/assets/assets-wrangler-test.mjs:65) - [SUGGESTION]
exists()assumes the disk service always sends an ETag, but the disk service only sets it when the file's modification time can be read (src/workerd/server/assets/assets.js:1310)
View full review
1. Empty or invalid _redirects crashes every request (BLOCKING). load() passes ...config into normalizeConfiguration, so redirects and headers hold the raw file text from wrangler.rs (assets.js:1345). constructRedirects returns {} when redirects.rules.length === 0 (assets.js:1114). That happens for an empty file, a comment-only file, or one where every rule is invalid. The raw string therefore survives configuration?.redirects ?? {...} (assets.js:190). staticRedirectsMatcher then reads .staticRules off a string and indexes undefined (assets.js:259-260). An empty _redirects is a common scaffold. _headers leaks the same way: it doesn't crash, but the per-configuration compile cache never hits for it. Fix: clear redirects and headers before spreading in the parsed versions. Add a regression test that loads _redirects text of "" and of "# comment\n".
2. Fields silently dropped without main (WARNING). When main is absent, workers == 0 and set_bindings, set_workflows_engine and set_durable_objects never run (wrangler.rs:384-428). vars, durable_objects and similar fields are accepted and ignored. queues, workflows and triggers.crons still generate services that target a Worker that doesn't exist. This contradicts the module's rule that an unsupported field is an error. Reject these fields with a clear message when main is missing.
3. Missing ETag throws (SUGGESTION). exists() calls res.headers.get('ETag').slice(...) unconditionally (assets.js:1310). The disk service only sets ETag when metadata.modified() succeeds.
4. Possible test flake (INFO). serve() in assets-wrangler-test.mjs resolves on the child's exit event. That event can fire before stderr has been drained, so the assertions on refused.stderr can see empty output. Resolve on close instead.
🔒 Security: 💬 1 suggestion
No exploitable issues. One hardening note: dotfiles are served by default.
Recommendation: 💬 Optional Nits
- [SUGGESTION] Dotfiles such as
.git/and.envare served from the assets directory by default; consider adding them to the default ignore list as Wrangler does (src/workerd/server/cli/wrangler.rs:610)
View full review
Path handling holds up. Paths are percent-decoded, . and .. segments are rejected, and segments are re-encoded before the disk request.
The FILES disk service allows dotfiles. The default ignore list only covers .assetsignore, _redirects and _headers. If the assets directory contains .git/, .env or node_modules, they are served, whereas Wrangler leaves such files out of uploads by default. The impact is low because this is a local server over a directory the user chose.
📝 Documentation: ⚠️ 1 warning
The README's list of supported Wrangler fields is out of date.
Recommendation: 📝 Minor Comments
- [WARNING] README says any field not listed is an error, but
assets(with--experimental) is now supported andmainis optional whenassetsis set (README.md:115)
View full review
README.md:111-116 lists the supported Wrangler fields and says that any other field is an error. With this change, assets is accepted under --experimental and main is optional when assets is set. Neither appears in that list.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in the changed files.
⚡ Performance: ✅ LGTM
No performance issues found. The per-request lookup memoization and the cost figures in the description are reasonable for a first version.
Reviewed commit: 4ed123fc
There was a problem hiding this comment.
Superseded by the review of
95c503d1.
This review, of 8c619c4e
_redirects crash is fixed in the Rust port, so nothing blocks this pull request. There are 4 WARNINGs: HEAD responses send Content-Length: 0, Worker-only fields are silently dropped when main is omitted, src/workerd/server/BUILD.bazel switched to crate labels that may not resolve, and the README's list of supported Wrangler fields is out of date.
Findings: 4 warnings · 3 info · 1 suggestion (5 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8475.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (4)
### [Code Quality] HEAD requests for an asset are answered with `Content-Length: 0` instead of the file's size
- **File:** src/workerd/server/server/services/assets/mod.rs:293
### [Code Quality] With `assets` and no `main`, Worker-only fields (`vars`, `durable_objects`, `queues`, `workflows`, `triggers.crons`) are still silently dropped or target a Worker that doesn't exist
- **File:** src/workerd/server/cli/wrangler.rs:392
### [Code Quality] Crate deps rewritten to `@crates_vendor//name`, while every other label uses the hub's `@crates_vendor//:name` aliases. This could not be checked against the generated repository in this run.
- **File:** src/workerd/server/BUILD.bazel:97
### [Documentation] README says any field not listed is an error, but `assets` (with `--experimental`) is now supported and `main` is optional when `assets` is set
- **File:** README.md:115
## INFO (3)
### [Code Quality] `_redirects` and `_headers` rules whose regex fails to compile are dropped without a warning
- **File:** src/workerd/server/server/services/assets/router/rules.rs:43
### [Code Quality] `serve()` resolves on the child's `exit` event, which can fire before stderr is drained, so the stderr assertions may flake
- **File:** src/workerd/server/tests/assets/assets-wrangler-test.mjs:65
### [Performance] Blocking `std::fs::metadata` runs on the async request path, possibly several times per request
- **File:** src/workerd/server/server/services/assets/mod.rs:85
## SUGGESTION (1)
### [Security] Dotfiles such as `.git/` and `.env` are served from the assets directory by default
- **File:** src/workerd/server/server/services/assets/router/ignore.rs:17
📋 Code Quality: ⚠️ 3 warnings · 2 info
The _redirects crash is fixed in the Rust port. Open: HEAD responses send Content-Length: 0, Worker-only fields are still dropped without main, the crate labels in BUILD.bazel are questionable, uncompilable rules are dropped silently, and the test harness can flake.
Recommendation: 📝 Minor Comments
- [WARNING] HEAD requests for an asset are answered with
Content-Length: 0instead of the file's size (src/workerd/server/server/services/assets/mod.rs:293) - [WARNING] With
assetsand nomain, Worker-only fields (vars,durable_objects,queues,workflows,triggers.crons) are still silently dropped or target a Worker that doesn't exist (src/workerd/server/cli/wrangler.rs:392) - [WARNING] Crate deps rewritten to
@crates_vendor//name, while every other label uses the hub's@crates_vendor//:namealiases. This could not be checked against the generated repository in this run. (src/workerd/server/BUILD.bazel:97) - [INFO]
_redirectsand_headersrules whose regex fails to compile are dropped without a warning (src/workerd/server/server/services/assets/router/rules.rs:43) - [INFO]
serve()resolves on the child'sexitevent, which can fire before stderr is drained, so the stderr assertions may flake (src/workerd/server/tests/assets/assets-wrangler-test.mjs:65)
View full review
🔄 Since last review: the BLOCKING _redirects crash and the missing-ETag suggestion are resolved, the main-less WARNING and the test-harness INFO are preserved, and there are 3 new findings.
The router now lives in Rust (server/services/assets/), not in /workerd/assets.js. The description still describes the JS module and a disk-service HEAD per lookup, but lookups now call std::fs::metadata in-process. Please update the description.
Findings
- HEAD reports
Content-Length: 0(mod.rs:293).Config::servesetsbody = falsefor HEAD as well as for 304, andrequest()sends the length only whenbodyis true. A HEAD for an asset therefore reports a length of 0 rather than the file's size. Fix: sendmetadata.len()for every status except 304, and copy the body only whenserved.bodyis true. - Worker-only fields ignored without
main(wrangler.rs:392). This is unchanged since the last review. Withassetsand nomain,set_bindings,set_workflows_engineandset_durable_objectsnever run, sovarsanddurable_objectsare accepted and then ignored.queues,workflowsandtriggers.cronsstill generate services that target a Worker that doesn't exist. Reject these fields with a clear error whenmainis missing. - Crate labels (
BUILD.bazel:97-108). These deps were rewritten from@crates_vendor//:nameto@crates_vendor//name. Every other label in the repository, including the newregexdep inserver/server/BUILD.bazel, uses the//:namealiases of thecrate.from_cargohub (build/deps/rust.MODULE.bazel:128-139).@crates_vendor//capnpmeans@crates_vendor//capnp:capnp, a package the hub may not define. This could not be checked against the generated repository in this run. - Uncompilable rules dropped silently (
rules.rs:43).RulesMatcher::newusesfilter_map, so a rule whose regex fails to compile is dropped without a warning. Examples are a repeated:name, or two*in a_redirectsrule, sinceparse_redirectsdoesn't callno_multiple_wildcards. - Test harness (
assets-wrangler-test.mjs:65).exitedresolves onexit, which can fire before stderr is drained, so the stderr assertions can flake. Resolve oncloseinstead.
🔒 Security: 💬 1 suggestion
Path handling holds up. One low-impact suggestion remains: dotfiles are served by default.
Recommendation: 💬 Optional Nits
- [SUGGESTION] Dotfiles such as
.git/and.envare served from the assets directory by default (src/workerd/server/server/services/assets/router/ignore.rs:17)
View full review
Path handling holds up:
- Segments go through
is_entry_name, and.and..are rejected. base_pathrejects backslashes, control characters and percent-encoding.- Placeholder substitution can't inject CR or LF.
- Redirect targets collapse slashes, so a protocol-relative redirect can't be produced.
- The
regexcrate matches in linear time, so a hostile_redirectsor_headersfile can't cause catastrophic backtracking.
One low-impact suggestion remains: the default ignore list covers only .assetsignore, _redirects and _headers. Files such as .git/ and .env in the assets directory are served.
⚡ Performance: 💬 1 info
Asset lookups use a blocking std::fs::metadata on the event loop.
Recommendation: 💬 Optional Nits
- [INFO] Blocking
std::fs::metadataruns on the async request path, possibly several times per request (src/workerd/server/server/services/assets/mod.rs:85)
View full review
Assets::stat calls std::fs::metadata synchronously, up to several times per request when html_handling probes candidates. This is cheap on a local disk. On a slow or network-mounted directory it stalls the event loop for every request. File bodies are streamed with copy_file, and config parsing happens once at startup.
📝 Documentation: ⚠️ 1 warning
The README's list of supported Wrangler fields still omits assets.
Recommendation: 📝 Minor Comments
- [WARNING] README says any field not listed is an error, but
assets(with--experimental) is now supported andmainis optional whenassetsis set (README.md:115)
View full review
README.md:111-116 lists the supported Wrangler fields and says that any other field is an error. With this change, assets is accepted with --experimental, and main can be omitted when assets is set. Neither appears in that list. This was raised in the last review and is unchanged.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in the changed files.
Reviewed commit: 8c619c4e
There was a problem hiding this comment.
Superseded by the review of
13a2a01f.
This review, of 95c503d1
💬 Approved with comments — All earlier WARNINGs in the code are fixed. Two WARNINGs remain: an .assetsignore pattern that fails to compile is dropped silently, so the file it should hide is served, and the README's list of supported Wrangler fields still says assets is an error.
Findings: 2 warnings · 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8475.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (2)
### [Code Quality] An `.assetsignore` pattern whose regex fails to compile is dropped silently, so the file it was meant to hide is served
- **File:** src/workerd/server/server/services/assets/router/ignore.rs:37
### [Documentation] README says any unlisted Wrangler field is an error, but `assets` is now supported with `--experimental` and `main` is optional when `assets` is set (README.md:116)
- **File:** README.md:116
## SUGGESTION (1)
### [Security] Dotfiles such as `.git/` and `.env` in the assets directory are served by default
- **File:** src/workerd/server/server/services/assets/router/ignore.rs:17
🔒 Security: 💬 1 suggestion
No vulnerabilities found. One optional hardening note remains open: dotfiles are served by default.
Recommendation: 💬 Optional Nits
- [SUGGESTION] Dotfiles such as
.git/and.envin the assets directory are served by default (src/workerd/server/server/services/assets/router/ignore.rs:17)
View full review
Path handling holds up. Segments go through is_entry_name, which rejects . and ... Rules compile with the linear-time regex crate.
The default ignore list covers only .assetsignore, _redirects and _headers. Files such as .git/ or .env in the assets directory are served unless the user lists them in .assetsignore. This matches production behaviour, so it is optional hardening.
📋 Code Quality: ⚠️ 1 warning
Earlier findings are fixed. One remains: an .assetsignore pattern whose regex fails to compile is dropped without a warning, so the file is served.
Recommendation: 📝 Minor Comments
- [WARNING] An
.assetsignorepattern whose regex fails to compile is dropped silently, so the file it was meant to hide is served (src/workerd/server/server/services/assets/router/ignore.rs:37)
View full review
🔄 Since last review: 6 findings resolved, 2 preserved, 1 new.
These earlier findings are fixed at this commit:
- A HEAD now sends the file's length, and only a 304 sends 0 (
services/assets/mod.rs:293-303). The e2e test checks this. - With
assetsand nomain, Worker-only fields are now an error, with tests. _headersand dynamic_redirectsrules that fail to compile are skipped with a warning (router/parse.rs).serve()in the wrangler e2e test waits forclose.src/workerd/server/BUILD.bazelis no longer changed.
The synchronous std::fs::metadata on the request path is intended, matching the disk service, as the author explained.
New finding
.assetsignorefails open (router/ignore.rs:37).Matcher::newdrops any pattern whose regex fails to compile, viaRegex::new(&re).ok()?, and reports nothing.glob_regexcopies a[...]class body almost verbatim, so a reversed range such assecret-[z-a].txtproduces an invalid regex. The file the user meant to exclude is then served._headersand_redirectsnow warn in this case;.assetsignoreshould do the same.
📝 Documentation: ⚠️ 1 warning
The README's list of supported Wrangler fields still says any other field, including assets, is an error.
Recommendation: 📝 Minor Comments
- [WARNING] README says any unlisted Wrangler field is an error, but
assetsis now supported with--experimentalandmainis optional whenassetsis set (README.md:116) (README.md:116)
View full review
README.md:111-117 lists the Wrangler fields workerd serve accepts and says "any other field is an error". With this pull request, assets is accepted with --experimental, and main can be omitted when assets is set. The README is not changed, so it now states something false about shipped behaviour. Add assets to the --experimental list, and say that main is optional with assets and that Worker-only fields then become an error.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in the changed files.
⚡ Performance: ✅ LGTM
File bodies are streamed with copy_file, and HEAD responses copy no body. As the author explained, the synchronous stat calls are intended.
Reviewed commit: 95c503d1
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8475 +/- ##
==========================================
- Coverage 66.57% 66.37% -0.20%
==========================================
Files 783 793 +10
Lines 201164 202636 +1472
Branches 31473 31479 +6
==========================================
+ Hits 133926 134501 +575
- Misses 48811 49707 +896
- Partials 18427 18428 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Superseded by the review of
955352ba.
This review, of 13a2a01f
💬 Approved with comments — Two WARNINGs remain from the last review: an .assetsignore pattern that fails to compile is skipped without a warning, so the file it should hide is served, and the README still lists assets among the fields that are an error. Nothing new was found in the code changed since then.
Findings: 2 warnings
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8475.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (2)
### [Code Quality] An `.assetsignore` pattern whose regex fails to compile is dropped silently, so the file it was meant to hide is served
- **File:** src/workerd/server/server/services/assets/router/ignore.rs:37
### [Documentation] README.md:111-117 says any Wrangler field not listed is an error, but `assets` is now supported with `--experimental`, and `main` is optional when `assets` is set
📋 Code Quality: ⚠️ 1 warning
One earlier warning is still open: .assetsignore fails open when a pattern's regex does not compile.
Recommendation: 📝 Minor Comments
- [WARNING] An
.assetsignorepattern whose regex fails to compile is dropped silently, so the file it was meant to hide is served (src/workerd/server/server/services/assets/router/ignore.rs:37)
View full review
.assetsignore fails open (router/ignore.rs:37). Matcher::new ends each pattern with Regex::new(&re).ok()? inside filter_map, so a pattern whose regex fails to compile is skipped and nothing is reported. glob_regex copies a [...] class body almost unchanged, so a reversed range such as secret-[z-a].txt produces an invalid regex. The file the user meant to exclude is then served.
_headers and _redirects rules that fail to compile already produce a warning through Config::parse's warn callback. .assetsignore is the only one of the three rule files that skips them silently, and it is the one that controls which files are served.
The code changed since the last review (wrangler.rs: the assets-only path, the Worker-only field errors, the --experimental check; the events test) has no new issues.
📝 Documentation: ⚠️ 1 warning
The README's list of supported Wrangler fields still says assets is an error.
Recommendation: 📝 Minor Comments
- [WARNING] README.md:111-117 says any Wrangler field not listed is an error, but
assetsis now supported with--experimental, andmainis optional whenassetsis set
View full review
README.md:111-117 lists the Wrangler fields that workerd serve accepts and ends with "any other field is an error". With this pull request, assets is accepted with --experimental, and main can be left out when assets is set. The README is not changed, so it now says something false about the shipped behaviour. Add assets to the --experimental list, and say that main is optional with assets and that Worker-only fields are then an error.
✅ All other checks passed
🔒 Security: ✅ LGTM
Path segments go through is_entry_name, which rejects . and .., and rules compile with the linear-time regex crate. The .assetsignore fail-open issue is covered in the Code Quality section. One earlier optional note is still open: dotfiles are served by default. You explained that this matches production, so it is not repeated here.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in the changed files.
⚡ Performance: ✅ LGTM
File bodies are streamed, and HEAD responses copy no body. As you explained, the synchronous stat calls on the request path are intended.
Reviewed commit: 13a2a01f
|
One thing needs fixing whatever else happens, and it comes first below. The rest is about 1. Don't resolve compatibility flags by hand. has("assets_navigation_prefers_asset_serving")
|| (date >= "2025-04-01" && !has("assets_navigation_has_no_effect"))This has to go. Turning a compatibility date plus explicit flags into flag
The factory already compiles the user Worker's flags ( The same pattern is already on main, in 2. Make 3. Keep 4.
It was the only difference in results I found between this and a port that 5. Have 6. Bring the upstream parity vectors along. I had golden vectors generated |
There was a problem hiding this comment.
Superseded by the review of
e38ad36b.
This review, of 955352ba
✅ Approved — Both earlier warnings (.assetsignore patterns skipped without a warning, and the stale README field list) are fixed, and nothing new turned up in the code changed since the last review.
Not opened by the correctness review: 11 changed files it was meant to read
src/rust/assets-router/parse.rssrc/rust/assets-router/rules.rssrc/rust/assets-router/serve.rssrc/workerd/server/cli/wrangler.rssrc/workerd/server/factory/worker-factory.c++src/workerd/server/factory/worker-factory.hsrc/workerd/server/server/BUILD.bazelsrc/workerd/server/server/bridge.rssrc/workerd/server/server/config.rssrc/workerd/server/server/services/assets/mod.rssrc/workerd/server/workerd.capnp
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
File lookups reject . and .. segments through is_entry_name and apply the ignore list before touching the file system. Rule patterns use the linear-time regex crate. The disk.rs changes only widen helpers to pub(crate).
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
📋 Code Quality: ✅ LGTM
An .assetsignore pattern that doesn't compile is now skipped with a warning through the same warn callback as _headers and _redirects, and a reversed-range test case covers it. Config::new now takes navigation_prefers_asset_serving as a boolean read from the compiled compatibility flags, instead of parsing the date and flags JSON itself. No new issues in the router crate, the wrangler translation or the assets service.
⚡ Performance: ✅ LGTM
File bodies are streamed, HEAD and 304 responses copy no body, and rule matching runs in linear time.
📝 Documentation: ✅ LGTM
README.md now lists assets under --experimental and describes serving files only, without main.
Reviewed commit: 955352ba
|
[AI] Thanks Dan, all six are in e38ad36.
|
There was a problem hiding this comment.
Superseded by the review of
a9c01cf2.
This review, of e38ad36b
💬 Approved with comments — One WARNING: a _headers header name with an invalid token character passes parsing, and every request its rule matches then fails at serve time. Plus one INFO and one SUGGESTION.
Findings: 1 warning · 1 info · 1 suggestion (3 are inline comments on the diff)
Not opened by the correctness review: 1 changed file it was meant to read
src/rust/assets-router/lib.rs
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8475.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] A `_headers` header name with invalid token characters is accepted at parse time and makes every matching response fail at serve time
- **File:** src/rust/assets-router/parse.rs:181
## INFO (1)
### [Code Quality] golden-test.rs header records upstream commit 2cd84d4 while lib.rs says the port is from dc47e6d2, and no generator exists to regenerate the vectors
- **File:** src/rust/assets-router/golden-test.rs:10
## SUGGESTION (1)
### [Code Quality] `Config::new` takes `has_user_worker` and `navigation_prefers_asset_serving` as adjacent bools that are easy to swap
- **File:** src/rust/assets-router/lib.rs:120
📋 Code Quality: ⚠️ 1 warning · 1 info · 1 suggestion
An invalid header name in _headers is accepted at parse time and then breaks every response its rule matches; there is also a provenance mismatch in the golden-test header and a two-adjacent-bool constructor.
Recommendation: 📝 Minor Comments
- [WARNING] A
_headersheader name with invalid token characters is accepted at parse time and makes every matching response fail at serve time (src/rust/assets-router/parse.rs:181) - [INFO] golden-test.rs header records upstream commit 2cd84d4 while lib.rs says the port is from dc47e6d2, and no generator exists to regenerate the vectors (
src/rust/assets-router/golden-test.rs:10) - [SUGGESTION]
Config::newtakeshas_user_workerandnavigation_prefers_asset_servingas adjacent bools that are easy to swap (src/rust/assets-router/lib.rs:120)
View full review
The issues raised on the earlier commits are all addressed at this commit:
- Worker-only fields without
mainare now an error. - HEAD responses send the file's length.
_headersand_redirectsrules that fail to compile warn.- Compatibility flags come from the Worker's compiled flags.
The synchronous stat on the loop thread and serving dotfiles by default are deliberate choices that match the disk service and production.
_headers header names are not validated as HTTP tokens (src/rust/assets-router/parse.rs:180-186, src/workerd/server/server/services/assets/mod.rs:101-102)
parse_headersrejects only names that are empty or contain a space. A name such asX@Foo,X(Y)orFoo/Baris stored without a warning.Assets::sendthen fails the whole response withinvalid header namewhenever the rule matches.- A typo in a
/*rule therefore turns every asset, redirect and 404 into an error. It happens at request time, and nothing points at the_headersline that caused it.
Golden vectors cite a different upstream snapshot than the port (src/rust/assets-router/golden-test.rs:8-12)
- The header records commit 2cd84d4 (2026-07-14).
lib.rssays the crate is ported from dc47e6d2 (2026-11-11). - There is no generator in the tree, so the vectors can't be regenerated as the header describes.
Config::new takes two adjacent bools (src/rust/assets-router/lib.rs:118-123)
has_user_workerandnavigation_prefers_asset_servinghave the same type and sit next to each other. Swapping them compiles and silently changes routing.
✅ All other checks passed
🔒 Security: ✅ LGTM
- Path traversal:
Assets::statrequires a leading/, rejects empty,.and..segments throughis_entry_name, and applies the ignore list before touching the file system. - Rule patterns: these use the linear-time
regexcrate. disk.rs: the changes only widen helper visibility.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
⚡ Performance: ✅ LGTM
File bodies are streamed, HEAD and 304 responses copy no body, and rule matching runs in linear time.
📝 Documentation: ✅ LGTM
The README updates match the behaviour.
Reviewed commit: e38ad36b
There was a problem hiding this comment.
Superseded by the review of
fe71e14a.
This review, of a9c01cf2
💬 Approved with comments — The earlier WARNING (_headers names not checked as HTTP tokens) is fixed, and so are the INFO and SUGGESTION. Two INFO notes on comment wording remain, and neither affects runtime behaviour.
Findings: 2 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 2 info
The earlier findings are fixed. Two comment-only notes remain.
Recommendation: 💬 Optional Nits
- [INFO] The
/// The rules of_headers`` doc comment is attached tois_token_charinstead ofheaders()(src/rust/assets-router/parse.rs:498) - [INFO] golden-test.rs header says "GENERATED — do not edit by hand" but also says to extend the vectors by hand (
src/rust/assets-router/golden-test.rs:8)
View full review
Earlier findings, checked at this commit
_headersheader names: fixed.parse.rsnow rejects names with characters outside the HTTP token set, with the error "Header name can only include token characters", andparse-test.rstests it.- Golden-vector header: now explains that the vectors come from 2cd84d4 and that the functions are unchanged up to dc47e6d2.
Config::new: takes aDeploymentstruct with named fields instead of two adjacentbools.
Remaining notes
parse.rs:498: the doc comment meant forheaders()sits on top ofis_token_char, andheaders()has no doc comment.golden-test.rs:8: the header says the file is "GENERATED — do not edit by hand", but a few lines later it says to extend the vectors by hand.
✅ All other checks passed
🔒 Security: ✅ LGTM
- Path handling:
Assets::statrequires a leading/, rejects empty,.and..segments, and applies the ignore list before it touches the file system. _headersnames: now validated as HTTP tokens when the file is parsed.- Base path: checked against the request's own path before any
_redirectsrewrite. - Rule patterns: compiled with the linear-time
regexcrate. A pattern that fails to compile, including an.assetsignorepattern, is skipped with a warning. - Image mitigations: the
/_imageand/_next/imagechecks fail closed.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
⚡ Performance: ✅ LGTM
File bodies are streamed. HEAD and 304 responses copy no body. The synchronous stat on the loop thread follows the same design as the disk service.
📝 Documentation: ✅ LGTM
The README updates match the behaviour.
Reviewed commit: a9c01cf2
Adds an `assets` service to workerd: a directory served as Cloudflare serves a Worker's static assets. Its router sends each request to the user Worker or to a file, as run_worker_first and the files ask, and its AssetWorker entrypoint backs a Worker's ASSETS binding. Events other than HTTP requests go to the user Worker. The routing, the _headers, _redirects, .assetsignore and run_worker_first parsers and the head of an asset's response are a side-effect-free crate, src/rust/assets-router, ported from workers-sdk's workers-shared at dc47e6d2, so that edgeworker can route with it too. The host in the server crate only stats files, streams them and forwards to the user Worker. Files are looked up as requests arrive, so nothing walks the directory at startup and a change to it is seen at once. An asset's ETag is a hash of its path, its size and its modification time; with the path in it, no two files are taken for the same asset. html_handling, not_found_handling and base_path behave as in production, as do the /_image block and the filter on _next/image responses. assets_navigation_prefers_asset_serving is compiled with the user Worker's compatibility flags, or, without one, with the service's own compatibilityDate and compatibilityFlags. A bad config is an error at startup; invalid _headers, _redirects and .assetsignore rules are warnings. With --experimental, assets in wrangler.json becomes one service, <name>-assets, with or without main. A wd-test checks that the router passes JS RPC, scheduled and tail events to the user Worker and that the AssetWorker entrypoint does not.
There was a problem hiding this comment.
Superseded by the review of
04438db2.
This review, of fe71e14a
✅ Approved — Both earlier INFO notes (parse.rs doc comment placement, golden-test.rs header wording) are fixed, and the changes since the last review add no new issues.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- Path handling:
Assets::statrequires a leading/, rejects.,.., separator and drive segments, and applies the ignore list before it touches the file system. _headersnames: checked as HTTP tokens when the file is parsed.- Rule patterns: a pattern that fails to compile is skipped with a warning.
disk.rs: the only change makes four helperspub(crate).
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
📋 Code Quality: ✅ LGTM
parse.rs: the_headersdoc comment is onpub fn headers, andis_token_charhas its owntcharcomment.golden-test.rs: the line saying the file is generated and must not be edited by hand is gone. The header explains where the vectors come from and how to extend them.regexis added withdefault-features = falseand thestdandperffeatures. The generated patterns use no Unicode classes, so they compile with that feature set.Cargo.lockandcargo-bazel-lock.jsonagree.
⚡ Performance: ✅ LGTM
_headers and _redirects are parsed once. The line, rule and length limits bound the work. The quadratic dedupe and validation loops run over at most 100 rules.
📝 Documentation: ✅ LGTM
The README updates match the behaviour.
Reviewed commit: fe71e14a
danlapid
left a comment
There was a problem hiding this comment.
Thanks, all six check out. I re-ran my differential harness against fe71e14a. Across ~2.5M cases it now gives the same results as a port that follows upstream, including the identical-content cases from point 4. Handing the asset worker only the manifest entries a request looked up still gives the same answers. The crate's tests pass, the golden vectors included, and I checked non-ASCII _redirects/_headers rules and run_worker_first globs against the reduced regex feature set.
Please do the Workflows mapping in cli/wrangler.rs (compatibility_date >= "2026-05-14" for workflows_replace_non_retryable_error_message) as a follow-up PR, with the same fix: compile the flags through compileCompatibilityFlags() instead of comparing dates.
# Conflicts: # README.md # src/workerd/server/cli/wrangler.rs
There was a problem hiding this comment.
Superseded by the review of
9ef883ff.
This review, of 04438db2
✅ Approved — No findings: the merge-from-main changes to wrangler.rs, bridge.rs and README.md are consistent, and the rest of the pull request is unchanged since the last approved review.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- Path handling:
Assets::statrequires a leading/. It rejects.,.., separator and drive segments, and applies the ignore list before any file-system access. wrangler.rs:assets.directorycomes from the local config, so it is not untrusted input.bridge.rs: the new FFI wrappers carry SAFETY comments that explain the lifetimes they rely on.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
📋 Code Quality: ✅ LGTM
wrangler.rs:mainis optional. The service count, the disk and D1 slot offsets and theassetsservice slot line up.- Without
main, Worker-only fields are rejected, andwrangler-test.rscovers this. - The socket targets
<name>-assetswhen assets are configured. check_experimentalcoversassets.
bridge.rs: theshould_block_image_response,new_image_filter_responseandimage_filter_finishdeclarations match their Rust and C++ definitions.
⚡ Performance: ✅ LGTM
Nothing new on the request path since the last review.
📝 Documentation: ✅ LGTM
The README.md changes from the merge match the behaviour.
Reviewed commit: 04438db2
|
recheck |
There was a problem hiding this comment.
✅ Approved — No findings: the merge-from-main changes to wrangler.rs, bridge.rs and README.md are consistent, and the rest of the pull request is unchanged since the last approved review.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- Path handling:
Assets::statrequires a leading/. It rejects.,.., separator and drive segments, and applies the ignore list before any file-system access. wrangler.rs:assets.directorycomes from the local config, so it is not untrusted input.bridge.rs: the new FFI wrappers carry SAFETY comments that explain the lifetimes they rely on.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the new crate layout.
📋 Code Quality: ✅ LGTM
wrangler.rs:mainis optional. The service count, the disk and D1 slot offsets and theassetsservice slot line up.- Without
main, Worker-only fields are rejected, andwrangler-test.rscovers this. - The socket targets
<name>-assetswhen assets are configured. check_experimentalcoversassets.
bridge.rs: theshould_block_image_response,new_image_filter_responseandimage_filter_finishdeclarations match their Rust and C++ definitions.
⚡ Performance: ✅ LGTM
Nothing new on the request path since the last review.
📝 Documentation: ✅ LGTM
The README.md changes from the merge match the behaviour.
Reviewed commit: 9ef883ff — same changes as 04438db2, so this is that commit's review (no new review was run; line numbers are as of 04438db2)
Adds an
assetsservice to workerd: a directory served the way Cloudflare serves a Worker's static assets. Its router sends each request to the user Worker or to a file, followingrun_worker_first,html_handling,not_found_handling,base_path,_headers,_redirectsand.assetsignoreas production does. ItsAssetWorkerentrypoint backs a Worker'sASSETSbinding. Every event other than an HTTP request (JS RPC, scheduled, tail) goes to the user Worker.It is native Rust. The routing, the rule parsers and the response headers are a side-effect-free crate,
src/rust/assets-router, ported from workers-sdk's workers-shared (at dc47e6d2) so that edgeworker can route with it too; the service in the server crate only stats files, streams them and hands requests to the user Worker.assets_navigation_prefers_asset_servingcomes from the user Worker's compiled compatibility flags. Files are looked up as requests arrive, so nothing scans the directory at startup and edits are served immediately. With--experimental,assetsin wrangler.json maps onto it.Performance
An earlier revision of this PR implemented the same port in JS: a bundled Worker that read files through a
diskservice. Both revisions measured with wrk against a 4 vCPU VM, requests/sec.In front of a Worker:
Assets only, no Worker:
For reference, a Worker that returns a constant response, with nothing in front of it, does about 12k on this VM. The JS revision paid one extra Worker hop per request and about 60µs per file lookup. Native p99 on file paths is ~9ms vs ~90ms, and with
run_worker_first: trueit reaches that 12k (JS: 6.4k). Code size: native is +2645 non-test lines vs +1704 for JS.Miniflare
No lockstep upgrade: unmodified Miniflare doesn't use this service, and its assets and core tests pass against this build. Miniflare pins an exact workerd version, so it adopts the service when it bumps that pin. The Miniflare side is cloudflare/workers-sdk#16932: it replaces Miniflare's own copies of the router, asset and assets-KV Workers, plus its RPC proxy, with this one service: +202 −667 lines, 133 of the added lines being generated config types.