openkfw / TruBudget

A blockchain-based workflow tool for efficient and transparent project management
https://openkfw.github.io/trubudget-website/
GNU General Public License v3.0
84 stars 39 forks source link

Consistent content of API responses #991

Open daniel-arnauer opened 2 years ago

daniel-arnauer commented 2 years ago

This issue is related to #940

Description 💡

The HTTP response bodies of API, excel-export, storage-service, email-service do not have a consistent format. This makes it very difficult to display human readable error messages in the frontend snackbar.

To resolve this issue, all HTTP error response bodies should have the same format that consists of:

For example, the current error response from the API looks like this:

{
   "apiVersion":"1.0",
   "error":{
      "code": 403,
      "message":"global.disableUser failed: failed to disable user: user root is not authorized for global.disableUser"
   }
}

This could be changed to:

{
   "apiVersion":"1.0",
   "error":{
      "code": 403,
      "stack":"global.disableUser failed: failed to disable user: user root is not authorized for global.disableUser",
      "message":"user root is not authorized for global.disableUser"
   }
}

Goal is to have a global TruBudget Convention/Standard that defines how HTTP Responses should look like in order to display user relevant information in the frontend (Message property in response).

Relates to/ Solves #111

TODOs

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity for 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity for 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed because of inactivity. You can re-open it if needed.

Stezido commented 2 years ago

TODOs:

Stezido commented 2 years ago

For the error standard: stackTrace and message should be part of the standard, where message is a readable reason