Skip to content

fix(dashboard): enforce image proxy limits while streaming - #1118

Merged
izadoesdev merged 4 commits into
databuddy-analytics:stagingfrom
maskjelly:fix/image-proxy-limit
Oct 17, 2026
Merged

izadoesdev merged 4 commits into
databuddy-analytics:stagingfrom
maskjelly:fix/image-proxy-limit

Conversation

@maskjelly

@maskjelly maskjelly commented Oct 9, 2026 •

Copy link
Copy Markdown

Description

The image proxy previously buffered an entire upstream response before applying its 2 MiB limit. This checks size while reading and cancels oversized or rejected responses early.

Slice

Changes

  • Enforce the 2 MiB limit during streaming even when Content-Length is absent or understated; use one bounded accumulation buffer and a deadline-aware stream pipe.
  • Cancel rejected or unread upstream bodies and retain the SSRF guard, redirect restriction, rate limit, response headers, and 10-second deadline.
  • Return 504 when the deadline interrupts body reading. The follow-up test holds a read pending and verifies the proxy aborts it without an abort-aware response stub.

Validation

  • bun run lint: passed.
  • bun run check-types: 37/37 tasks passed.
  • bun test app/api/image-proxy/route.test.ts: 11 passed, including oversized streams, exact-limit success, rejected-body cancellation, read failure, SSRF rejection, and a stalled body interrupted by the deadline.
  • The timeout regression uses a controlled response stream; a live network stall was not run in this follow-up.

Merge notes

This is an independent change based on current staging. The 2 MiB bound applies to application accumulation; the fetch implementation supplies each incoming chunk. Maintainer review and CI are still required.

Before merge

  • Maintainer applies the suggested label and reviews the change.
  • Run the fork CI workflow (currently action_required with zero jobs).
  • Resolve the Vercel authorization check failures shown on the PR.

AI disclosure: implemented and tested with Codex. Source and local test results were reviewed during implementation; maintainer human review is required.

@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown

@maskjelly is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – documentation October 9, 2026 22:50 Inactive
@maskjelly
maskjelly marked this pull request as ready for review October 9, 2026 22:50
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
documentation Skipped Skipped Oct 17, 2026 5:49pm UTC

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6edb4914-b29b-45e3-83c9-97a72044c14d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Image proxy streaming and size enforcement logic.

The streaming change appears sound, but the explicit code-rule violations must be resolved before merging.

Findings

  1. P2 Required code rules are broken ▶
  2. P2 Body timeout lacks coverage ▶

Summary

The image proxy now checks each chunk before copying it into a fixed 2 MiB buffer.

  • The image proxy stops oversized streams at the 2 MiB limit.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Fetch image with deadline] --> B{Headers accepted?}
  B -->|No| G[Cancel upstream body]
  B -->|Yes| C[Read next chunk]
  C --> D{Exceeds 2 MiB?}
  D -->|Yes| G
  D -->|No| E[Copy into fixed buffer]
  E --> C
  C -->|End of body| F[Return populated bytes]
  C -->|Deadline error| H[Return 504]
  F --> G
  H --> G
Loading

Reviews (1) · Last reviewed commit: "fix(dashboard): enforce image proxy limi..." · Reviewed by Greptile

Comment thread apps/dashboard/app/api/image-proxy/route.ts Outdated
Comment thread apps/dashboard/app/api/image-proxy/route.test.ts Outdated
@izadoesdev
izadoesdev force-pushed the fix/image-proxy-limit branch from ed6c3e6 to 47503ef Compare October 17, 2026 17:49
@vercel
vercel Bot temporarily deployed to Preview – documentation October 17, 2026 17:49 Inactive
@izadoesdev
izadoesdev merged commit d1a2af8 into databuddy-analytics:staging Oct 17, 2026
13 of 16 checks passed

This branch was previously deployed

1 inactive deployment
Preview – documentation — 47503ef5 Deployed Oct 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants