Skip to content

Treat the status line as Cloudflare's primary purge signal - #8

Merged
Meldiron merged 1 commit into
mainfrom
feat-cloudflare-status-first
Aug 17, 2026
Merged

Treat the status line as Cloudflare's primary purge signal#8
Meldiron merged 1 commit into
mainfrom
feat-cloudflare-status-first

Conversation

@Meldiron

Copy link
Copy Markdown
Contributor

What

Aligns the Cloudflare adapter's success check with the Fastly adapter: an HTTP 2xx is acceptance, and the response envelope's explicit verdict is honored when present — a success: false inside a 2xx still fails the purge, but a 2xx without a parseable envelope no longer does.

Why

Cloudflare's v4 API reports failures with non-2xx status codes; the envelope duplicates that verdict. Requiring the envelope to be present meant a 2xx whose body a gateway rewrote, a proxy dropped, or a test double never sent was reported as a failed purge that had actually been accepted — the caller then retries or alerts on nothing. Keeping the explicit-success: false override preserves the one real protection the body check provided.

Tests

  • testAcceptsAPurgeWithoutTheEnvelope — 200 with an empty body is acceptance
  • testRejectsAPurgeTheBodyReportsAsFailed — unchanged: explicit success: false in a 2xx still rejected
  • testRejectsAPurgeTheStatusReportsAsFailed — a failing status is not softened by the envelope

Suite: 52 tests, 115 assertions, green. Pint and PHPStan pass.

🤖 Generated with Claude Code

The adapter required the response envelope to be present and carry
success: true, so any 2xx whose body a gateway rewrote, a proxy dropped,
or a test double never sent was reported as a failed purge. Cloudflare
signals failures with a non-2xx status; the envelope's verdict is kept
as an override, so an explicit success: false inside a 2xx still fails,
but the envelope's absence no longer does.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes Cloudflare purge handling treat an HTTP 2xx status as acceptance unless a parsed response envelope explicitly reports failure.

  • Preserves rejection of non-2xx responses and success: false envelopes.
  • Accepts successful responses with empty or unparseable bodies.
  • Adds focused tests for missing envelopes and status-level failures.

Confidence Score: 5/5

The PR appears safe to merge with no blocking or independently actionable non-blocking issues identified.

The changed logic rejects every non-2xx response and any parsed envelope whose explicit success verdict is not true, while intentionally accepting 2xx responses without a usable envelope as described and tested.

Important Files Changed

Filename Overview
src/Cdn/Cache/Adapter/Cloudflare.php Updates purge-success evaluation to prioritize HTTP status while retaining explicit envelope failure handling; no actionable defect was identified.
tests/Cdn/Cache/Adapter/CloudflareTest.php Adds coverage for empty successful responses and non-2xx failures while preserving explicit body-failure coverage.

Reviews (1): Last reviewed commit: "Treat the status line as Cloudflare's pr..." | Re-trigger Greptile

@Meldiron
Meldiron merged commit 31d6e0e into main Aug 17, 2026
4 checks passed
@TorstenDittmann
TorstenDittmann deleted the feat-cloudflare-status-first branch August 17, 2026 10:58
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