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

Improve Http response code handling / Backend Validations #34

Open
norbertbede opened this issue Nov 11, 2020 · 1 comment
Open

Improve Http response code handling / Backend Validations #34

norbertbede opened this issue Nov 11, 2020 · 1 comment

Comments

@norbertbede
Copy link

norbertbede commented Nov 11, 2020

example use case
the frontend developer has the task to make an app for requests, he doesn't know detail about which fields are mandatory, so he sends a request method POST with the missing field they are mandatory in the backend.

Backend report SQL error on insert - and return 500 http status code without any valuable information

09:34:45.162===========> DB.saveError: DBExecuteError - ERROR: null value in column "summary" violates not-null constraint
  Detail: Failing row contains (1004800, 1000014, 0, Y, 2020-11-11 09:34:45.12, 1131504, 2020-11-11 09:34:45.12, 1131504, INC1000051, 1000067, null, null, null, null, null, 7, 7, 5, null, A, N, N, null, 1000265, null, null, null, N, N, null, 1131504, null, null, null, null, null, null, null, null, null, null, null, 0.0, null, null, A, null, null, null, null, null, 0, 0, null, null, null, null, null, null, null, null, null, null, null, 91e7ae36-6a62-4942-93e7-fccb49006a11, null, null, null, null, 0, null, null, null, null). [6038]

awaited behavior
REST API validate in this case mandatory logic and return instead HTTP status code 500 => HTTP status code 400 Bad Request. Response Body must include in login language - Error eg. Summary Field is Mandatory.

This can be applied to other logics like field format (eg,. phone validation), field type string vs numeric, etc.

FOR Me looks really important this topic, because we implemented a middleware in a customer project, where our vendor has no information about errors and we need each error to ask by email...etc.

Need meeting in MatterMost, what is our possibilities and time plan.

@d-ruiz
Copy link
Collaborator

d-ruiz commented Dec 8, 2020

@norbertbede,

I created a new IdempiereRestException class to handle this things, you can go ahead and improve the cases that you know are failing, the exception receives two parameters (errorMessage, Error status)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants