Repository navigation
Report mailroom storage errors as server errors - #2070
Open
Christopherdominic wants to merge 1 commit into
Open
Christopherdominic wants to merge 1 commit into
Christopherdominic wants to merge 1 commit into
Conversation
Collaborator
Coverage Report for CI Build 47002240871Coverage increased (+0.1%) to 87.887%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
caarloshenriq
left a comment
Contributor
There was a problem hiding this comment.
Concept ACK 72f9177
Mapping looks right: V1SenderUnavailable reaches put_payjoin_v1 intact through the db service layer, and reverting that call to BadRequest makes the new 410 test fail. Responses stay empty, so the unexpected-variant message only goes to the log.
One thing before ACK: the receiver treats 4xx as fatal and 5xx as transient, so moving operational errors on the v1 response from 400 to 500 changes receiver behavior from aborting to retrying. That's probably what we want, but the commit message and changelog should describe it as a change (inline). Happy to ACK once that's updated.
put_payjoin_v1 mapped every storage error to 400 Bad Request, so a failing backend looked like a malformed client request in the response status, the request metrics, and the logs. post_mailbox mapped every storage error to 500, including a full mailbox store, which mailbox reads already report as 503. Move the mapping that handle_peek already had into a shared handle_db_error and use it for both writes. Operational failures become 500, a full store 503, and a v1 response for a sender that is no longer waiting 410, matching what reads return. This changes v1 receiver behavior on operational storage failures. Receivers treat 4xx as fatal and 5xx as transient, so a v1 response that previously aborted on 400 now retries on 500; retrying a backend failure is intended. With the files backend post_v1_response only reports V1SenderUnavailable, so the status observed there moves from 400 to 410 and remains fatal. Closes payjoin#420.
Christopherdominic
force-pushed
the
mailroom-db-error-status
branch
from
December 3, 2026 00:18
72f9177 to
370446b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #420.
put_payjoin_v1mapped every storage error to400 Bad Request, so a failing backend showed up as a malformed client request in the response status, the request metrics (status_codelabel) and the logs (awarn!"Bad request" instead of anerror!).post_mailboxmapped every storage error to500, including a full mailbox store, which mailbox reads already report as503.This moves the mapping that
handle_peekalready had into a sharedhandle_db_errorand uses it for both writes:put_payjoin_v1post_mailboxOperationalOverCapacityV1SenderUnavailableWith the files backend,
post_v1_responseonly returnsV1SenderUnavailable, so in practice the visible change there is 400 → 410 for a receiver replying after the v1 sender left. TheOperationalmapping matters for any otherDbimplementation.Client impact: handler errors leave the gateway unencapsulated, so clients see these as the outer HTTP status. This is a behavior change on the v1 response path: receivers treat
4xxas fatal and5xxas transient, so an operational storage failure that used to abort on400now retries on500. Retrying a backend failure is intended. With the files backend,post_v1_responseonly returnsV1SenderUnavailable, so the visible change there is400 → 410, which stays fatal.Tests
put_v1_response_with_no_waiting_sender_returns_gone: a PUT through the gateway with no waiting sender returns 410. It fails with 400 against the old mapping.storage_errors_map_to_server_side_statuses: unit test ofhandle_db_errorfor each variant.Adds a
payjoin-mailroom/changelog.d/storage-error-statuses.mdfragment.Checked locally:
cargo fmt --all -- --check,cargo clippy --all-targets --keep-going --all-features -- -D warnings,cargo test -p payjoin-mailroom --all-features,contrib/release/changelog-fragments.sh payjoin-mailroom/changelog.d.codespelldidn't complete locally (nix shell timed out), so I'm relying on CI for that.Reviewer: @DanGould
AI disclosure: the change, commit message and this description were drafted with AI assistance (Claude Code). A local AI review of the branch was run against the AGENTS.md criteria with no findings.
Pull Request Checklist
Please confirm the following before requesting review: