Skip to content

feat: [SIW-2159] Handle presentation errors #223

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

Merged
merged 26 commits into from
May 13, 2025

Conversation

gispada
Copy link
Collaborator

@gispada gispada commented Apr 18, 2025

List of Changes

  • Added sendAuthorizationErrorResponse function to notify the RP
  • Created RelyingPartyResponseError class with RP-specific error codes
  • Explicitly handled 400 and 403 HTTP status code when sending the Authorization Response
  • Thrown InvalidRequestObjectError in verifyRequestObject for validation-related errors
  • Thrown DcqlError in evaluateDcqlQuery to unify DCQL-related errors
  • Refactored some error related utils and types
  • Updated the example app
  • Added more tests

Motivation and Context

This PR improves the error handling in the presentation flow, by providing a specific RelyingPartyResponseError and a function to notify the Relying Party of any errors occurred when processing the Authorization Request.

How Has This Been Tested?

Tested against the test Relying Party instance, using the example app and a proxy to simulate 400, 403 and 500 HTTP status codes, with the following body:

{
    "error": "invalid_request",
    "error_description": "An error occurred"
}

Screenshots (if appropriate):

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@ChrisMattew ChrisMattew left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@mastro993 mastro993 left a comment

Choose a reason for hiding this comment

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

LGTM

@gispada gispada merged commit 63865de into master May 13, 2025
7 checks passed
@gispada gispada deleted the SIW-2159-presentation-errors branch May 13, 2025 07:09
github-merge-queue bot pushed a commit to pagopa/io-app that referenced this pull request May 15, 2025
…#6917)

> [!WARNING]
> Depends on [this
PR](pagopa/io-react-native-wallet#223)

## Short description
This PR adds handling for certain potential errors in the remote
presentation flow.

## List of changes proposed in this pull request
- Implemented an error screen that allows users to retry the remote
presentation if a communication error occurs during the auth/response
step.
- Implemented an error screen to inform the user when the RP fails to
verify the Authorization Response. This screen will provide some useful
details about the encountered error.
- Implemented an error screen shown when the RP returns a non-compliant
Request Object.

## Demo
<details><summary>Auth Response Errors</summary>
<p>

| Communication Error | Verification Error|
|--------|--------|
|<video
src="https://github.com/user-attachments/assets/ad045d7c-3cde-47ac-9654-1497ce21aded"></video>|
<video
src="https://github.com/user-attachments/assets/c6fa7a53-da0a-446b-830b-9b305888eb47"></video>|

</p>
</details> 

<details><summary>Non-Compliant Request Object</summary>
<p>

| Invalid Req Obj | Invalid Dcql Query |
|--------|--------|
|<video
src="https://github.com/user-attachments/assets/d33fffb4-438d-4c2f-95ef-8163c1d5b7b9"></video>|
<video
src="https://github.com/user-attachments/assets/c6295b97-2af8-49c5-afb1-124b75e7ff1f"></video>|

</p>
</details> 

## How to test
### Auth Response Error
Using a proxy tool (I used Proxyman), intercept the POST request to
`auth/response` to simulate a communication error (such as a 500 status
code) or a validation error returned by the RP (status code 400 or 403),
in order to display the two error screens shown in the demo.
### Non-Compliant Request Object
- **Invalid Request Object:**
- From the
`node_modules/@pagopa/io-react-native-wallet/src/credential/presentation/05-verify-request-object.ts`
file, make the `verifyRequestObject` function throw an
`InvalidRequestObjectError`.
- **Invalid Dcql Query:** 
- In the `ts/features/itwallet/presentation/remote/machine/actors.ts`
file, modify the `requestObject.dcql_query` value before calling
`evaluateDcqlQuery`.

> [!NOTE]
> The tests shown in the demo were performed using the test RP

---------

Co-authored-by: Gianluca Spada <[email protected]>
Co-authored-by: RiccardoMolinari95 <[email protected]>
github-merge-queue bot pushed a commit to pagopa/io-app that referenced this pull request May 15, 2025
…#6917)

> [!WARNING]
> Depends on [this
PR](pagopa/io-react-native-wallet#223)

## Short description
This PR adds handling for certain potential errors in the remote
presentation flow.

## List of changes proposed in this pull request
- Implemented an error screen that allows users to retry the remote
presentation if a communication error occurs during the auth/response
step.
- Implemented an error screen to inform the user when the RP fails to
verify the Authorization Response. This screen will provide some useful
details about the encountered error.
- Implemented an error screen shown when the RP returns a non-compliant
Request Object.

## Demo
<details><summary>Auth Response Errors</summary>
<p>

| Communication Error | Verification Error|
|--------|--------|
|<video
src="https://github.com/user-attachments/assets/ad045d7c-3cde-47ac-9654-1497ce21aded"></video>|
<video
src="https://github.com/user-attachments/assets/c6fa7a53-da0a-446b-830b-9b305888eb47"></video>|

</p>
</details> 

<details><summary>Non-Compliant Request Object</summary>
<p>

| Invalid Req Obj | Invalid Dcql Query |
|--------|--------|
|<video
src="https://github.com/user-attachments/assets/d33fffb4-438d-4c2f-95ef-8163c1d5b7b9"></video>|
<video
src="https://github.com/user-attachments/assets/c6295b97-2af8-49c5-afb1-124b75e7ff1f"></video>|

</p>
</details> 

## How to test
### Auth Response Error
Using a proxy tool (I used Proxyman), intercept the POST request to
`auth/response` to simulate a communication error (such as a 500 status
code) or a validation error returned by the RP (status code 400 or 403),
in order to display the two error screens shown in the demo.
### Non-Compliant Request Object
- **Invalid Request Object:**
- From the
`node_modules/@pagopa/io-react-native-wallet/src/credential/presentation/05-verify-request-object.ts`
file, make the `verifyRequestObject` function throw an
`InvalidRequestObjectError`.
- **Invalid Dcql Query:** 
- In the `ts/features/itwallet/presentation/remote/machine/actors.ts`
file, modify the `requestObject.dcql_query` value before calling
`evaluateDcqlQuery`.

> [!NOTE]
> The tests shown in the demo were performed using the test RP

---------

Co-authored-by: Gianluca Spada <[email protected]>
Co-authored-by: RiccardoMolinari95 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants