Repository navigation
fix: Fall back when a decorated cache engine cannot increment - #63
Conversation
DebugKit wraps every configured cache in a DebugEngine, so the instanceof FileEngine guard in VerifyRateLimiter::increment() does not match and the second counted failure throws "Files cannot be atomically incremented". Catch the LogicException and use the existing read/write fallback. The increment is called on the pool engine directly: Cache::increment() only declares InvalidArgumentException, which hides the LogicException the engine documents. Closes dereuromark#62 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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 |
|
Update on the side note about the The |
Closes #62.
With DebugKit loaded,
Cache::pool()returns aDebugEnginedecorator, so theinstanceof FileEngineguard inVerifyRateLimiter::increment()does not match. The second counted failure then throwsLogicException: Files cannot be atomically incremented.This change catches the
LogicExceptionand uses the existing read/write fallback. Theinstanceofguard stays as the fast path for undecorated engines. The increment is called on the pool engine directly.Cache::increment()only declaresInvalidArgumentException, so PHPStan flags a catch around it as dead, even though the engine underneath documents theLogicException.Tests: a new
testDecoratedFileCacheFallbackwraps aFileEnginein a minimal test-app decorator shaped likeDebugEngine, so the suite needs no DebugKit dependency. It fails with theLogicExceptionon master and passes with the fix. Full suite: 70 tests, 305 assertions. PHPStan (viacomposer stan-setup) and PHPCS pass locally.Also checked end to end in an app with DebugKit 5.2.4 and a File cache: invalid submissions are throttled again instead of crashing.
Not addressed here: the
Undefined array key "prefix"warning fromRateLimitRegistry::acquireLock()mentioned in #62. It comes fromDebugEnginenot proxyingadd()and is better fixed in DebugKit.🤖 Generated with Claude Code