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.

Non-semantic use of error code 400

See original GitHub issue

Observed behavior

A couple of places, API calls will return HTTP 400

A 400 means that the request was malformed. In other words, the data stream sent by the client to the server didn’t follow the rules.

If the username already exists (see: https://github.com/learningequality/kolibri/pull/3125 ) then the HTTP status code 400 is used as the sole condition.

Another example:

https://github.com/learningequality/kolibri/blob/79c6a9046b153656c61c01b9375109d3ff395ae5/kolibri/plugins/user/assets/src/views/sign-up-page/index.vue#L192

I don’t think it’s that bad, but I don’t think we should assume anything from the HTTP status code. Some people even argue that 200 is more correct for a form processing where data doesn’t validate… because frankly, there’s no exception taking place in the server, and the client is using the API correctly.

Let’s find and add a standard for form validation errors? cc: @mrpau-eugene @indirectlylit @rtibbles

Expected behavior

Backend errors should resolve through correct error codes that do not mis-guide developers.

User-facing consequences

None

Errors and logs

n/a

Steps to reproduce

n/a

Context

n/a

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
indirectlylitcommented, Mar 21, 2018

Let’s make this a focus of the next milestone after 0.9. I think we should take a step back and do some design work on all this together.

0reactions
indirectlylitcommented, Aug 27, 2018

This should be addressed. @ralphiee22 mind linking your error-handling PR here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix a 400 Bad Request Error (Causes and Fixes) - Kinsta
The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived...
Read more >
400 Bad Request - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request ......
Read more >
What is HTTP error 400 and how do you fix it? - IT PRO
A 400 Bad Request error can occur when the DNS data stored locally is out of sync with a website's registered DNS information...
Read more >
Status Code 400 (Bad Request) Explained & How to fix it - Ryte
A status code 400 or a code 4xx indicates a client error. When the client sends an invalid request to the server, the...
Read more >
How to Fix a 400 Bad Request Error: 8 Easy Methods
The 400 bad request error is an HTTP status code that describes an error caused by an invalid request. Thus, the server can't...
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