Skip to content

fix(images): preserve bodyless responses with size headers - #1386

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-bodyless-image-content-length
Aug 10, 2026
Merged

fix(images): preserve bodyless responses with size headers#1386
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-bodyless-image-content-length

Conversation

@luvs01

@luvs01 luvs01 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Treat a response with no body as zero bytes before evaluating its Content-Length metadata.
  • Preserve bodyless image relay statuses such as 204 even when an upstream sends an oversized or stale Content-Length header.
  • Extend the live image relay regression so this header cannot turn a bodyless response into a synthetic 502.

Follow-up to #1346 (comment).

Verification

  • Bun 1.3.14: bun test tests/server-images.test.ts — 63 passed.
  • bun run typecheck — passed.
  • bun run privacy:scan — passed.
  • git diff --check HEAD^ HEAD — passed.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed; none are required for this internal response-body correction.
  • Security-sensitive changes were reviewed for untrusted upstream metadata and fail-closed behavior.

Review readiness checklist

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of image responses with no body.
    • Prevented empty responses with oversized declared content lengths from being incorrectly treated as oversized image data.
    • Preserved expected behavior for successful empty responses.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

readImageResponseBytes now returns zero bytes for null response bodies without marking them oversized. The related test covers a 204 response with an oversized Content-Length header and no response body.

Changes

Image response handling

Layer / File(s) Summary
Null body handling and regression coverage
src/server/images.ts, tests/server-images.test.ts
At lines 87–89, readImageResponseBytes returns an empty, non-oversized result when the response body is null. The test at lines 786–789 verifies this behavior for a 204 response with an oversized Content-Length header.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: wibias, ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving bodyless image responses when size headers are oversized or stale.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@luvs01
luvs01 force-pushed the agent/fix-bodyless-image-content-length branch from 4d72783 to 9b44acc Compare August 10, 2026 00:41
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

@github-actions
github-actions Bot marked this pull request as ready for review August 10, 2026 01:38

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 9b44acc. The production change correctly handles a null response body before Content-Length validation, which fixes the bodyless-response false oversize case while preserving the existing abort and bounded-body behavior. Cross-platform CI and React Doctor are green. Non-blocking note: the motivating standards-compliant example is a 304 with Content-Length; the regression uses a 204 with Content-Length, which is a malformed upstream case. The implementation still covers both, so this is not a merge blocker.

@Wibias
Wibias merged commit d178531 into lidge-jun:dev Aug 10, 2026
31 of 32 checks passed

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @luvs01! 🙏 This is a clean, focused fix for the bodyless image-response edge case. Merged into dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants