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

api: enhance error reporting with custom error codes and messages #136

Open
2 of 3 tasks
Piiit opened this issue Jun 29, 2021 · 5 comments
Open
2 of 3 tasks

api: enhance error reporting with custom error codes and messages #136

Piiit opened this issue Jun 29, 2021 · 5 comments

Comments

@Piiit
Copy link
Contributor

Piiit commented Jun 29, 2021

  • @Piiit checks if it is related to the deployment (proxy, redirects or authentication)
  • if not, @SirCotare will fix the bug --> return the correct error code and message
  • as stated in the comments, the error messages are sometimes wrong or too noisy
@Piiit Piiit self-assigned this Jun 29, 2021
@Piiit Piiit added the bug Something isn't working label Jun 29, 2021
@Piiit
Copy link
Contributor Author

Piiit commented Jun 30, 2021

@SirCotare @danielecanu
I checked this now, and it seems that when no 'Authorization' header is attached to the call the following error message is shown:

{
  "errorCode": 400,
  "message": "Request method 'PATCH' not supported",
  "stacktrace": ""
}

This is misleading I think, we should instead show an unauthorized error code and message. Could you please fix that?

With the Bearer token headers the PATCH commands seem to work (tested only with /admin/webcomponent/f594de36-0136-4c27-a0e6-570fa7014129/v1.8.1/metrics)

@Piiit Piiit removed their assignment Jun 30, 2021
@Piiit
Copy link
Contributor Author

Piiit commented Jul 1, 2021

@SirCotare It seems that this is somehow the "default" error message... If I send a wrong JSON with a call, it does not show that the payload is wrong but also "PATCH not supported error"

SirCotare added a commit to konverto-development/it.bz.opendatahub.webcomponents that referenced this issue Jul 9, 2021
@Piiit
Copy link
Contributor Author

Piiit commented Jul 13, 2021

We will check this with #148

@Piiit
Copy link
Contributor Author

Piiit commented Jul 14, 2021

I tested this and the PATCH error is no longer wrongly shown, however the error messages are still very noisy...

For example:

POST /admin/webcomponent/f594de36-0136-4c27-a0e6-570fa7014129
Content-Type: application/json
Authorization: Bearer {{token}}

shows

{
  "errorCode": 400,
  "message": "Validation failed for argument [1] in public it.bz.opendatahub.webcomponents.dataservice.application.adapter.in.web.admin.rest.WebcomponentVersionAdminRest it.bz.opendatahub.webcomponents.dataservice.application.adapter.in.web.admin.WebcomponentVersionAdminController.createNewVersion(java.lang.String,it.bz.opendatahub.webcomponents.dataservice.application.port.in.CreateWebcomponentVersionUseCase$WebcomponentVersionCreateRequest): [Field error in object 'webcomponentVersionCreateRequest' on field 'configuration': rejected value [null]; codes [NotNull.webcomponentVersionCreateRequest.configuration,NotNull.configuration,NotNull.it.bz.opendatahub.webcomponents.common.data.struct.Configuration,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [webcomponentVersionCreateRequest.configuration,configuration]; arguments []; default message [configuration]]; default message [must not be null]] ",
  "stacktrace": ""
}

if a wrong JSON format has been given. Those error messages should not just pass-thru whatever the exception throws, but give a meaningful hint to the API user.

@Piiit
Copy link
Contributor Author

Piiit commented Jul 23, 2021

The nice user-facing error messages needs to be written custom and not just passed through the Bean validation tooling. It is not easy to implement, needs a lot of work, and is not blocking. Therefore, we decided to implement it in a future iteration...

To be clear, related bugs are solved

@sseppi sseppi added enhancement New feature or request and removed bug Something isn't working labels Jul 23, 2021
@Piiit Piiit changed the title api: PATCH not supported error api: enhance error reporting with custom error codes and messages Jul 23, 2021
@Piiit Piiit added prj:webcomp and removed enhancement New feature or request labels Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants