Skip to content

Expose Receiver Error Kinds#1428

Open
chavic wants to merge 3 commits intopayjoin:masterfrom
chavic:chavic/receiver-error-variants-1270
Open

Expose Receiver Error Kinds#1428
chavic wants to merge 3 commits intopayjoin:masterfrom
chavic:chavic/receiver-error-variants-1270

Conversation

@chavic
Copy link
Copy Markdown
Collaborator

@chavic chavic commented Mar 20, 2026

Closes #1270.

This PR exposes the receiver protocol error structure that already existed in core but was being flattened at the FFI boundary. Before this change, bindings could tell that a receiver protocol error happened, but they could not reliably distinguish malformed original payloads, malformed v1 requests, and v2 session failures, or inspect the details that matter for control flow.

The change adds stable classifications for protocol, payload, request, and session errors, along with targeted detail accessors for the fields that are operationally useful now, such as supported versions, header name, invalid content type, and expected versus actual content length. The FFI continues to use stable object wrappers rather than freezing every internal Rust enum variant directly into the cross-language API.

The result is that bindings can now branch on receiver failures in a structured way instead of scraping display strings. That gives downstream integrations a usable receiver-side error contract and sets the pattern for the remaining receiver error work.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 20, 2026

Pull Request Test Coverage Report for Build 23742597279

Details

  • 93 of 120 (77.5%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 84.066%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/receive/v1/error.rs 40 44 90.91%
payjoin/src/core/receive/v2/error.rs 9 13 69.23%
payjoin/src/core/receive/error.rs 44 63 69.84%
Totals Coverage Status
Change from base Build 23607944477: -0.06%
Covered Lines: 10742
Relevant Lines: 12778

💛 - Coveralls

@chavic chavic requested a review from benalleng March 22, 2026 09:51
@chavic chavic self-assigned this Mar 22, 2026
@chavic chavic marked this pull request as ready for review March 22, 2026 09:52
Copy link
Copy Markdown
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really prefer we not use ..Issue as the naming convention in the case of preventing Dart Exception classes, lets use PayloadFailure, RequestFailure, SessionFailure instead

@chavic
Copy link
Copy Markdown
Collaborator Author

chavic commented Mar 29, 2026

I would really prefer we not use ..Issue as the naming convention in the case of preventing Dart Exception classes, let's use PayloadFailure, RequestFailure, SessionFailure instead

I see, just merged a PR in uniffi-dart upstream to fix the Dart failures, should help with future error name issues, and can use the better names. I'm thinking of renaming it back to the original PayloadError, RequestError, SessionError

chavic added 3 commits March 30, 2026 12:39
Add stable kind accessors for receiver protocol, payload,\nrequest, and session errors in the core crate and surface\nmatching snapshot objects over UniFFI.\n\nBindings could previously only tell that a receiver protocol\nerror happened, not whether the failure came from the original\npayload, the v1 HTTP request, or the v2 session machinery.\nThat made cross-language integrations parse display strings or\ntreat actionable failures as opaque.\n\nThe new accessors preserve the existing display behavior while\nmaking the branchable error shape available to Rust and FFI\ncallers. Focused tests cover the core accessors and the FFI\nmapping for payload and request failures.
Point the Dart generator dependency at the merged upstream fix\nfor object types ending in Error.\n\nThis replaces the temporary downstream workaround path with the\nupstream uniffi-dart revision that contains the naming fix, so the\nreceiver bindings can keep their original Error names.
Refresh the minimal and recent lockfiles after upgrading\nuniffi-dart to the upstream revision with the Dart naming fix.\n\nThis keeps the branch's resolved dependency graph aligned with the\nCargo.toml change used by CI and local testing.
@chavic chavic force-pushed the chavic/receiver-error-variants-1270 branch from 71f2fda to 452c379 Compare March 30, 2026 11:33
@benalleng benalleng self-requested a review March 30, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose typed error variants for receiver errors in FFI bindings

3 participants