Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose error code/response body to OpenPaymentsClientError #482

Closed
sidvishnoi opened this issue Jun 24, 2024 · 4 comments · Fixed by #484 or #485
Closed

Expose error code/response body to OpenPaymentsClientError #482

sidvishnoi opened this issue Jun 24, 2024 · 4 comments · Fixed by #484 or #485
Assignees

Comments

@sidvishnoi
Copy link
Member

sidvishnoi commented Jun 24, 2024

Context: Web Monetization extension

If a user revokes key from wallet, all subsequent requests (to auth.rafiki.money in this case) error with HTTP 400 + invalid_client. But this code isn't available to client to check whether it's a 400 due to invalid_client or some other reason. The response body says invalid_client, but we can't access the body on error.

Exposing this (GNAPErrorCode in case of auth server) in OpenPaymentsClientError would help us gracefully handle interledger/web-monetization-extension#332

@sidvishnoi
Copy link
Member Author

sidvishnoi commented Jun 25, 2024

Also, would be helpful to have access to error messages from the resource server
(like Signature validation error: could not find key in list of client keys in this case)

@sidvishnoi sidvishnoi changed the title Expose GNAPErrorCode to OpenPaymentsClientError in client Expose error code/response body to OpenPaymentsClientError in client Jun 25, 2024
@sidvishnoi sidvishnoi changed the title Expose error code/response body to OpenPaymentsClientError in client Expose error code/response body to OpenPaymentsClientError Jun 25, 2024
@mkurapov
Copy link
Contributor

For this, I merged in a PR in rafiki that adds proper GNAP error objects in the auth server:

We will publish a new version of Rafiki (alpha 14) such that the test wallet can be updated with this new change.

In the meantime, I'll edit the client so it can surface up the proper error (for now, the OpenPaymentsClientError will contain code: string that will have invalid_client on those errors).

In my opinion this should be a larger effort to actually add all of the possible error codes to both the AS and the RS specs, so they are obvious to the users of Open Payments 👍 I'll bring it up in the next Open Payments catch up call

@sidvishnoi
Copy link
Member Author

Can possibly include in error description until codes are finalized?

@mkurapov
Copy link
Contributor

Can possibly include in error description until codes are finalized?

In this Open Payments example error:

image

I'd imagine the corresponding OpenPaymentsClientError will be as such:

try {
} catch (err) { 
  err.code  // "invalid_client"
  err.description // "Could not determine client"
}

@mkurapov mkurapov added this to Rafiki Jul 2, 2024
@mkurapov mkurapov moved this to Todo in Rafiki Jul 2, 2024
@mkurapov mkurapov self-assigned this Jul 3, 2024
@mkurapov mkurapov moved this from Todo to Ready for Review in Rafiki Jul 3, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Open Payments Jul 3, 2024
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Rafiki Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
2 participants