question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document errors that could occur within 4xx/5xx

See original GitHub issue

In providing quality documentation, it’s necessary to provide more than “400 - Bad Request”. Usually, an error object defines a key which indicates more specifically what was wrong (this applies to 5xx range as well), usually referred to as an ‘error code’ (not the HTTP status code). In addition, when testing for whether a given error is intended to be produced by a given operation, it’s helpful to have the verb/uri/status correlated to a given ‘error code’. At a minimum, all potential ‘error codes’ should be documented for a given API (realm of verbs+uri’s+statuses). These ‘error codes’ could be numeric (e.g. 100100) or strings (e.g. AUTHORIZATION_VOIDED). The field/key they are mapped to could be variable, such as code, name.

Examples: https://developer.paypal.com/docs/api/#errors https://stripe.com/docs/api#errors

We store proprietary data to keep track of these correlations, at an API level (representing a group of verb/url/statuses):

"x-errors" : [
    {
      "name": "MALFORMED_REQUEST_ERROR",
      "message": "Json request malformed.",
      "information_link": "http://developer.paypal.com/apidoc/invoicing#MALFORMED_REQUEST_ERROR",
      "details" : "The Json request is malformed. Please check the request and resend the request."
    },
    // Long-list ensues

It would be very helpful to have the ability to specify what the ‘error code’ field is in error responses, and to provide a list of these errors. Defining them at a swagger.yaml level is a minimum, and at an operation/status level would be the most granular (probably useful in testing precision).

Perhaps in the spirit of #398, defining a global list of status codes would be useful, in addition to specific ‘error codes’.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:25
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
andy-maiercommented, Feb 1, 2018

@tadhgpearson: Your example shows the current shortcoming: There is only one piece of information for each HTTP status code. Many HTTP status codes above 400 can have multiple reasons, each. These reasons cannot be properly documented today. What is needed is:

  • The ability to define multiple reason codes including a message, for each HTTP status code.
  • The ability to define these reason codes globally, and the ability to reference these global definitions in the definition of an HTTP operation. Basically, each HTTP operation would reference a list of tuples (HTTP status code, reason code).

I definitely second the original request.

5reactions
sedapsfognikcommented, Nov 28, 2021

Would love to see this one in the next releases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling all HTTP errors (4xx/5xx) in global.asax file
How can I get HTTP errors to go through the Application_Error method of the global.asax file? Testing with errors such as 403 and...
Read more >
Search Latency/4xx/5xx Error Issue
Problem Any latency or search/category API errors Debugging Steps To investigate the issue and the reason, follow the steps below: Contact your technical ......
Read more >
Edge Errors -- Content Delivery (HTTP 4xx and 5xx errors)
This alert notifies you that a percentage of requests from the edge servers with the HTTP 4xx and 5xx status codes reached a...
Read more >
Troubleshoot your Application Load Balancers
A registered target is not in service. If a target is taking longer than expected to enter the InService state, it might be...
Read more >
Question: HTTP Client Errors in Boomi
What type of error will be thrown by HTTP connector if the server throws any of 4xx,5xx ? .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found