Closed mejo- closed 1 year ago
Actually returning 500 is done on purpose, because an Exception is thrown. I thought that this would actually be helpful for the JS client to detect the failure. The response also contains a meaningful error message:
I'm not sure what's the best response for an API call if the to-be-created object already exists. Do you have suggestions @azul?
In GitLab by @azul on Mar 10, 2021, 18:03
@mejo- My suggestion would be 422 - Unprocessable Entity:
The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.
I would like to avoid 500 - Internal Server Error as much as possible exactly because it can be caused by any other error. Parsing the message inside the response can be error prone. Plus rejecting a new collective with an existing name is desired server behaviour - not an unexpected error.
mentioned in commit 254369825a45f324b6f0299e98e1bc1a249e582d
That makes a lot of sense, agreed :blush:
The backend now returns a 422 when trying to create an existing collective. But we still have to improve the frontend so that it shows a more meaningful message.
In GitLab by @azul on Mar 14, 2021, 22:41
@mejo- I'm tempted to just open the collective if the user happens to be a member of it. I'd still display a meaningful error message. Any reason not to do so from your point of view?
Yeah, I really like that idea :blush:
In GitLab by @azul on Apr 2, 2021, 10:47
So I think we want different html response codes for this:
In GitLab by @azul on Apr 5, 2021, 21:18
The merge request that closed this issue (!166) addressed the first 3 scenarios. Creating a collective for an existing circle and the corresponding 403 will be handled as part of #115 .
In GitLab by @azul on Sep 7, 2020, 09:47
We should either handle the error and respond somewhat meaningfully or adjust the name for example with a
(2)
postfix.