Close the webhook idempotency gap BL0's final review found

FixBillingService
Ya
26 Agosti 2026, 03:33 UTC
Mwandishi
Kamo
Ahadi ya
27d3200

Finding 1 (Critical): a losing claim on a redelivered Stripe event only proved a row existed, not that the prior attempt finished. A claimed row left behind by a transient failure (Yugabyte 40001, a Hikari timeout, a unique-constraint race) looked identical to a genuine duplicate, so the redelivery answered 200 and Stripe permanently stopped retrying a money write that never landed. Added **************** (its own REQUIRES_NEW read) so a losing claim is judged on whether processed actually flipped to true; an unprocessed row now throws **************** instead of returning, so the controller answers 500 and Stripe's three-day retry window stays open. Finding 2 (Important): markProcessed discarded its row count. A zero-row update was invisible and left the event silently unprocessed forever, with nothing failing anywhere. It now asserts exactly one row was updated and throws otherwise; the javadoc records the Yugabyte snapshot-isolation reasoning that makes this safe today and fragile if a repository read is ever added ahead of the claim. Finding 4 (Minor): the controller logged the absent-Stripe-Signature- header case at ERROR, same as a genuine missing-secret misconfiguration. That endpoint is public and internet-reachable, so any caller could generate ERROR lines on demand by omitting the header. WebhookNotConfiguredException now carries a callerCaused flag; the controller logs WARN for the header case and reserves ERROR for the case that is actually ours to fix. Tests: pinned both directions of the new claim gate behaviourally (StripeWebhookClaimGateTest, with a real HMAC-signed payload) and via source-shape (StripeWebhookIdempotencyTest); the markProcessed row-count assertion behaviourally with a mocked repository **************** and the WARN/ERROR split behaviourally via a Logback ListAppender **************** Verified all three are load-bearing by reverting each fix in turn, confirming the corresponding new tests go red, then restoring and confirming green. Full suite: 208 tests, 0 failures, 0 errors (up from 193 at 674fa0f).

Mabadiliko yote

Je, unaona nini kuhusu usafiri?

Kila moja ya hizi updates ardhi katika nafasi yako ya kazi moja kwa moja. Kuanza bure na kuangalia kukua wiki baada ya wiki.

Kuwa Huru MileleMtazamo wa bei