fix(server): preserve compressed asset content types #11768
main fromrefs/pull/11768/head·opened View on GitHubHTML and CSS workspace assets larger than the compression threshold lost their Content-Type header. Browsers then treated HTML as plain text and rejected sibling styles under nosniff.
Carry the inferred MIME type and content length on the file response body so Effect compression preserves the response metadata. Add an HTTP regression test that exercises a compressed HTML asset through the real middleware.
Verified with:
- vp test run apps/server/src/http.test.ts apps/server/src/assets/AssetAccess.test.ts
- vp lint apps/server/src/http.ts apps/server/src/http.test.ts --report-unused-disable-directives
- vp fmt --check apps/server/src/http.ts apps/server/src/http.test.ts
- Browser verification with a 4.8 KB HTML file and 4.6 KB linked CSS file, both Brotli-compressed with correct MIME types
The server package typecheck still reports existing errors in HostPowerMonitor.ts and NativeTelemetryClient.ts, unrelated to this change.
Model: GPT-5.6-Sol. Harness: Codex in T3 Code.
Summary by CodeRabbit#
Bug Fixes
- Preserved the correct content type and content length when serving compressed assets.
- Ensured compressed asset previews continue to return the expected response body and MIME type.
Tests
- Added coverage verifying asset responses retain correct headers and content when compression is enabled.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
b0cf29dMacroscope's review found this PR approvable — This is a narrowly scoped server fix that preserves existing MIME metadata through compression, with an integration test covering compressed HTML responses and body integrity. The production impact is localized to file-backed asset delivery and introduces no configuration, schema, or deployment changes.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
79d5ff5e-987c-4042-aaa1-6eb516b4f005📥 Commits
Reviewing files that changed from the base of the PR and between 33118d9ab263904e4180b3bf2cbf0a36fe0695e2 and b0cf29d74dde43a4cc0578fc71faf3a392005090.
📒 Files selected for processing (2)
apps/server/src/http.test.tsapps/server/src/http.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
assetFileResponsenow preserves inferred MIME types when compression middleware processes raw file bodies. A new integration test verifies gzip encoding, HTML content type, and unchanged response content.Changes#
Asset compression
Layer / File(s) Summary Preserve asset content types
apps/server/src/http.tsassetFileResponserebuilds raw response bodies with an inferred content type and the existing content length.Validate compressed asset responses
apps/server/src/http.test.tsThe test serves an HTML file through HttpMiddleware.compression()and verifies gzip encoding,text/html; charset=utf-8, and the original body.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
chrisdeemingMerge Risk: ⚪ Minimal · up to
b0cf2The asset response change preserves MIME metadata through compression without retaining an invalid compressed-response length. The change is ready to merge.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Title check ✅ Passed The title clearly identifies the server fix: preserving content types for compressed assets. Description check ✅ Passed The description clearly explains what changed, why it changed, the regression test, verification steps, and unrelated typecheck failures. It does not use the template headings or checklist, but the re… Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
claude-opus-5-5on behalf of MariaHi! We are cleaning up open PRs, and this one appears to have been created with an older model (
gpt-5.6-sol). If this change is really important, we recommend rebuilding the PR with a newer model if possible.maria-rcks closed this
Sign in to join this conversation.
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.