Skip to content

Handle bad key configuration - #617

Closed
spacebear21 wants to merge 3 commits into
payjoin:masterfrom
spacebear21:handle-bad-key-configuration
Closed

spacebear21 wants to merge 3 commits into
payjoin:masterfrom
spacebear21:handle-bad-key-configuration

Conversation

@spacebear21

@spacebear21 spacebear21 commented Mar 31, 2025 •

Copy link
Copy Markdown
Collaborator

Address #615

This is still a draft because I noticed some related issues that must be addressed first:

  • process_response methods return inconsistent error types when POSTing vs. GETting, specifically: EncapsulationError vs. ResponseError for send and SessionError vs. Error for receive.
  • Those error types are currently opaque, so the caller can't switch on specific variants.
  • There are four duplicated variants between InternalEncapsulationError and InternalSessionError.
    • Also, EncapsulationError is a misnomer since it afaict it's exclusively raised when decapsulating responses.
    • The Hpke variant has nothing to do with en/decapsulation.

This whole module is feature-gated behind "v2" already.
The `process_res` methods across send and receive have a lot of shared
code that can be extracted into reusable functions. `process_get_res`
and `process_post_res` essentially do the same thing, and could
conceivably be combined into one function. They were kept separate
because "202 Accepted" is not a valid response for POST requests.
Clients with bad OHTTP key configurations should not retry requests to
the directory with the same key configuration, so they must be able to
switch on that error variant.
@coveralls

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 14181755436

Details

  • 44 of 81 (54.32%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 81.407%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/receive/v2/mod.rs 6 7 85.71%
payjoin/src/ohttp.rs 29 39 74.36%
payjoin/src/receive/v2/error.rs 0 12 0.0%
payjoin/src/send/v2/error.rs 0 14 0.0%
Totals Coverage Status
Change from base Build 14175113914: -0.3%
Covered Lines: 5219
Relevant Lines: 6411

💛 - Coveralls

@DanGould

Copy link
Copy Markdown
Member

@spacebear21 and I discussed this. From what I recall, it does make sense to handle a bad key configuration during the initial session initialization but not thereafter, since the KeyConfiguration should only be used if it's supposed to be valid for the duration of the payjoin expiry period.

How to handle #615 is still unclear but the first two commits here seem like improved changes and should land.

@spacebear21

Copy link
Copy Markdown
Collaborator Author

The first commit has already landed in master. Second commit moved to #660. Closing this PR.

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.

3 participants