Repository navigation
[StaticAssets] Avoid caching responses for missing manifest assets - #70062
Conversation
Avoid clearing a missing manifest asset response back to an empty 200. Return 404 with no-store so transient deployment gaps cannot poison the browser HTTP cache. Let the invoker handle missing development files without reading their unavailable length. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Required frozen-revision review evidence was unavailable, leaving approval checks incomplete and requiring final human review.
No open issues 🎉
What changed in this PR
This PR prevents missing manifest-backed static assets from producing cacheable empty responses. It addresses server-side prevention for #69488 without clearing already-poisoned browser caches.
Changes:
- Return
404withCache-Control: no-storeand log missing assets. - Check file existence before reading metadata in development runtime patching.
- Add eight HTTP integration cases covering environment, compression, prior requests, and asset restoration.
| File | Description |
|---|---|
src/StaticAssets/test/StaticAssetsIntegrationTests.cs |
Tests missing-asset responses and recovery after restoration. |
src/StaticAssets/src/StaticAssetsInvoker.cs |
Returns and logs non-cacheable missing-file responses. |
src/StaticAssets/src/Development/StaticAssetDevelopmentRuntimeHandler.cs |
Guards metadata access when the source file is missing. |
Review effort: Balanced
|
/review |
There was a problem hiding this comment.
Reviewed frozen head a4464fe530d7c421c2dd456dce65315159c4675a against merge base 6e70df47c3a16e5b06d8b610ff95414c212c2bfd and base tip/guidance commit 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af.
One P2 finding: missing manifest assets still use stale fast-path responses for HEAD and matching conditional requests because the new non-cacheable 404 is reached only while sending a body. The fix should perform a fresh file-provider existence check before request precondition/HEAD fast paths and retain the catch for deletion races.
The routed docs/CrossCuttingGuidance.md review completed with gpt-5.6-sol (runtime effort default; runtime-reported model matched). It assessed all in-scope cross-cutting topics; security assessment and worker-side execution were explicitly excluded. No public API, analyzer, trimming/AOT, package, template, or metadata change was present. No material changed area lacked routed guidance.
Existing feedback contained no equivalent actionable finding: the bot review reported no open issues but noted unavailable frozen evidence, the human review was approval-only, and the invocation comment contained only /review. This is deduplication, not endorsement. There were no unresolved candidates.
Coordinator validation used the supplied worktree at the exact frozen SHA. After installing the pinned SDK and targeted restore, a temporary two-case TestServer test warmed the endpoint, deleted the asset, then sent HEAD or GET with the prior ETag. dotnet test ./src/StaticAssets/test/Microsoft.AspNetCore.StaticAssets.Tests.csproj -c Debug --no-restore /p:UseIisNativeAssets=false /p:RunAnalyzers=false --filter FullyQualifiedName~MissingAssetFastPathsReturnNonCacheableNotFound failed 2/2: HEAD observed 200 and conditional GET observed 304 where 404 was expected. The temporary test was removed. An initial run was unavailable before SDK setup; one targeted restore attempt used an incorrect relative project path before the absolute-path restore succeeded. No repository-wide test suite or browser workflow was run.
Limitations: review evidence is tracked Git content only; symlink, submodule, and LFS targets are inert. Feedback posted after bundle preparation was not observable.
Generated by ASP.NET Core Pull Request Review for #70062 · copilot · gpt56 · 132.4 AIC · ⌖ 31.2 AIC · ⊞ 20K
Comment /review to run again
PureWeen
left a comment
There was a problem hiding this comment.
One additional issue was validated at the frozen head.
Human-directed and GitHub Copilot-generated.
Co-authored-by: Copilot <[email protected]>
Check current file-provider state before HEAD, precondition, and invalid range responses, retaining the existing send/catch path for ordinary GETs. Share non-cacheable missing-file handling with development runtime patching so retained compressed artifacts cannot hide a deleted original source. Add 52 regression rows covering cached metadata and source-only deletion. All new rows failed before the fix; all 124 StaticAssets tests pass. Co-authored-by: Copilot <[email protected]>
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. |
|
✅ No documentation PR was created. Confidence that documentation is needed: 10% No docs needed: the PR fixes missing manifest asset handling to return a non-cacheable 404. No public API, configuration or template signals were found. Documentation surfaces considered
|
|
/backport to release/11.0 |
|
Started backporting to |
…70062) (#70302) Co-authored-by: Pavel Savara <[email protected]>
[StaticAssets] Avoid caching responses for missing manifest assets
Return non-cacheable 404s when a manifest asset disappears.
Description
When a file referenced by a static-assets manifest disappears,
StaticAssetsInvokercatchesFileNotFoundExceptionand clears the response. Clearing resets it to an empty 200 response. A browser can cache that response and later reuse it for a fingerprinted Blazor boot resource.Cache-Control: no-storeafter clearing the missing-file response, and log the missing asset.Validation
Commands were run from the repository root after
. .\activate.ps1.Before the fix: 8 failed, 0 passed, 0 skipped. The four production cases returned an empty 200 instead of 404; the four development cases threw
FileNotFoundExceptionwhile reading the missing file's length.After the fix: 70 passed, 0 failed, 0 skipped, including all eight new cases.
Analyzers were temporarily disabled on the command line with the author's authorization because the unmodified dependency projects fail public-API analyzers locally. No analyzer suppression or build workaround is included in this PR. No browser E2E tests were run for this server-only change; the regression is exercised at the real HTTP static-asset endpoint via TestServer.
Contributes to #69488; this server-side prevention change does not by itself resolve existing poisoned browser caches.
Contributes to dotnet/runtime#135090
Note
This PR was generated with GitHub Copilot and reviewed and validated in a local coding session.