Repository navigation
fix(CloudflarePurger): catch TransferException so connect timeouts are logged - #17
Conversation
…e logged purge() caught GuzzleHttp\Exception\RequestException. In Guzzle 7, ConnectException extends TransferException directly and is a sibling of RequestException, not a subclass of it, so a connect or DNS timeout to api.cloudflare.com never reached the handler written to log it. Instead it escaped purge(), aborted the deferred update and was reported as an unhandled error. Catching TransferException covers both branches, so a timed-out purge produces the intended "Cloudflare purge failed" log line and a false return. The purge is still lost - the stale-cache and egress-connectivity problems behind these timeouts are separate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AiEBkhzV1z9bEykvEU9U8j
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
The failing check It fails at the PKSA-rdkp-vv9z-mjkg (OS command injection, affects The same check is red on No fix is included here. Upstream has one: Generated by Claude Code |
51.0.0 pins squizlabs/php_codesniffer 3.13.5, which Composer now refuses to install because of advisory PKSA-rdkp-vv9z-mjkg (CVE-2026-67434, OS command injection, affects <3.13.6). CI fails at the Composer install step before any test runs. 51.0.1 requires php_codesniffer 3.13.6, outside the advisory range. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AiEBkhzV1z9bEykvEU9U8j
Requested by Thomas · Slack thread
Addresses Sentry
MEDIAWIKI-CCK(64 events, 23 users affected).Before: Every edit and file upload queues a Cloudflare cache purge as a deferred update. When the request to
api.cloudflare.comfailed to connect within the 3-second connect timeout — 0 bytes received — the error was not caught.purge()has a handler written to log exactly this and return false, but it catchesRequestException, and Guzzle 7 raises aConnectExceptionfor a connect or DNS timeout. So the exception sailed past the handler, aborted the deferred update, and surfaced as an unhandled error in Sentry, with no "Cloudflare purge failed" line in the logs to say what had gone wrong.After: A connect or DNS timeout is caught by the same handler as any other transfer failure. The purge logs
Cloudflare purge failedwith the hook, the purge body and the error message, returns false, and the deferred update finishes normally instead of throwing. The Sentry noise stops and the failure becomes visible where it was meant to be visible.How: One-line change in
includes/CloudflarePurger.php— thecatchinpurge()now takesGuzzleHttp\Exception\TransferExceptioninstead ofGuzzleHttp\Exception\RequestException(theusestatement changed to match), with a comment recording why. In Guzzle 7 bothConnectExceptionandRequestExceptionextendTransferExceptiondirectly;ConnectExceptionis a sibling ofRequestException, not a subclass, so it was never covered. Verified against guzzle/guzzle 7.9 source:class ConnectException extends TransferException implements NetworkExceptionInterfaceandclass RequestException extends TransferException implements RequestExceptionInterface. The method is otherwise untouched.What this does not fix
api.cloudflare.comis failing to establish a connection within 3 seconds. That is worth investigating separately — it is why the purges are failing at all.Verification
php -l includes/CloudflarePurger.php→No syntax errors detected in includes/CloudflarePurger.phpcomposer test(the repo's own script: parallel-lint, minus-x, phpcs) →Note that
composer testin this repo is lint and style only — parallel-lint, MinusX and PHPCS. There are no unit tests here and no test coverage ofCloudflarePurger, so the run above says the change is syntactically and stylistically clean, not that the new catch was exercised. The behaviour is established from the Sentry stack traces and from Guzzle's class hierarchy as quoted above.🤖 Generated with Claude Code
https://claude.ai/code/session_01AiEBkhzV1z9bEykvEU9U8j
Generated by Claude Code