fix: Handle run-test-payment failures safely - #153
ValeraFinebits wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a safety boundary around cheat-mode test payments to prevent plugin or host shutdowns.
Changes:
- Returns
400for null request bodies. - Logs unexpected failures while preserving cancellation behavior.
- Updates null-body test coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
UIPayJoinController.cs |
Adds validation and exception handling. |
UIPayJoinControllerTests.cs |
Verifies null bodies return 400. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
chavic
left a comment
There was a problem hiding this comment.
Requesting changes for the missing regression coverage.
The implementation passes locally. However, the committed tests do not cover the exception boundary this PR adds. Please add cases that verify:
- An ordinary exception returns a structured failure response.
- Cancellation of the actual request propagates.
- An OperationCanceledException without a cancelled request token returns a failure response.
I tested these cases locally. All 273 tests passed with the current implementation. I then deliberately broke each behavior in an isolated copy. The 270 existing unit tests still passed; the added cases detected each regression.
Please assert the failure response without requiring raw exception text. That leaves room to return a generic client message while logging the details.
@chavic Done. |
POST /plugins/payjoin/run-test-paymentthrew on a malformed body and let anyfailure from the payjoin flow escape the action. BTCPay reacts to an exception
escaping plugin code by disabling the plugin and stopping the host, so a bad
request or a transient RPC error took the whole dev server down. The endpoint is
[CheatModeRoute], so this only hit cheat-mode servers, which is where themanual test plan runs.
400instead of throwingArgumentNullException.RunTestPaymentCoreAsync, wrapped in a catch that logs andreports. A genuine cancellation is still re-thrown.