← Back to Pull requests

feat(miniflare): emit `Cf-Resized` error header on `cf.image` fail-open and support `quality`/`flip`/`blur`/`sharpen` #17219

Open
unknown opened this pull request with 195 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 27, 2026 05:17 UTC
Author

Problem

1. When local cf.image fails to transform an origin image (e.g. corrupt/non-image body or unsupported SVG), Miniflare fails open to the source bytes with HTTP 200 but omits the Cf-Resized: err=<code> header that production sets—making Cf-Resized error-checking untestable locally.
2. Local Sharp transforms ignored output({ quality }) on the env.IMAGES binding as well as flip, blur, and sharpen on both env.IMAGES and cf.image.

Before / After

# Before (local cf.image on invalid image body)
HTTP/1.1 200 OK
content-type: image/png
(no Cf-Resized header)

# After (matches production fail-open error signaling)
HTTP/1.1 200 OK
content-type: image/png
cf-resized: err=9412

  • Sets cf-resized: err=<code> on cfImageError() (9412 decode/transform failure, 9520 SVG input, 9401 malformed request, 9523 Sharp unavailable) and forwards it in outbound.worker.ts on fail-open.

  • Reads output_quality in imagesLocalFetcher and passes { quality } to Sharp jpeg()/webp()/avif().

  • Applies flip (h/v/hv), blur, and sharpen in both runTransform() and applyCfImageTransforms().

  • <!-- devin-review-badge-begin -->

    ---

    <a href="https://cloudflare.devinenterprise.com/review/cloudflare/workers-sdk/pull/17219" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    Diff: 195 lines (+146 / -49) across 2 files Reviewer: NuroDev Review duration: 6327m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.36) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 195 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.316
    Real PR Conversation Timeline
    1 comments
    "Review active on #17219"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36% (MEDIUM) · Higher = larger blast radius
    36%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.6% · Safe to merge
    20.6%