Fix 500 in payment status read when a concurrent webhook locks the data element#1804
Conversation
|
Warning Review limit reached
More reviews will be available in 56 minutes and 44 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|



Description
Problem
GET …/payment(GetPaymentInformation) intermittently returned 500 after a successful payment.The endpoint persists the latest payment status on read when the requested task is the current task. This races with the payment webhook, which advances the process and locks the payment data element. The persist
PUTto storage then fails with409 - "data element <id> is locked and cannot be updated", which surfaced to the user as a 500 — typically right after returning from the hosted payment page.Why the existing mitigation missed it
GetPaymentInformationalready guarded this race: on a persist failure it calledCurrentTaskMovedAwayFromand only degraded to a read-only result if it could confirm the current task had moved. But the data-element lock can become visible before theCurrentTaskchange does, so in that window the re-check still saw the payment task as current → the 409 was rethrown → 500. This made it intermittent ("some users").Fix
Treat a
409/Conflictfrom t back to read-only paymentstatus, without requiring the task-moved check — the lock itself is the authoritative signal that a c) already finalized things.Non-409 exceptions keep their previous behavior (still propagate when the taskmoved).Testing
Adds a regression test,
GetPaymentInformation_PersistFailsWithLockedDataElement_FallsBackToReadOnly,reproduces the production scel storage needed): the persist throwsPlatformHttpException(409, "…is locked…")with the current task left unchanged, and the endpoithe read-only status. TheexistingPersistFailsButTaskUnchanged_PropagatesExceptiontest confirms non-409 errorsstill propagate.
🤖 Generated with Claude Code
Frontend PR adding retries in order to further harden the process-flow:
Altinn/app-frontend-react#4259
Related Issue(s)
Verification
Documentation