The Wayback Machine - https://web.archive.org/web/20201114071342/https://github.com/ExpressGateway/express-gateway/issues/593
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

Return the proper status codes from the WebAPI #593

Open
XVincentX opened this issue Jan 2, 2018 · 12 comments
Open

Return the proper status codes from the WebAPI #593

XVincentX opened this issue Jan 2, 2018 · 12 comments

Comments

@XVincentX
Copy link
Member

@XVincentX XVincentX commented Jan 2, 2018

If not for some particular exceptions, the status code returned from our WebAPI on error is always 500, regardless of the kind of error.

If an object already exists, for example, it should be returned as 409. If the object does not pass the schema validation, it should be a 415.

Go through the whole WebAPI and verify that the status codes are being returned correctly.

Hint: Error class's got a name property as well that can be used to identify the error type.

@XVincentX XVincentX self-assigned this Jan 2, 2018
@XVincentX XVincentX added this to The eternal backlog in Technical debt via automation Jan 2, 2018
@iwko
Copy link
Contributor

@iwko iwko commented Feb 12, 2018

I can work on it.

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 13, 2018

That'd be great. Do you know where to look at or do you need any guidance?

@iwko
Copy link
Contributor

@iwko iwko commented Feb 13, 2018

@XVincentX /lib/rest/ is the place where I should make changes?

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 14, 2018

Correct. One example would be here

@iwko
Copy link
Contributor

@iwko iwko commented Feb 14, 2018

@XVincentX please assign me

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 19, 2018

Go for it @iwko

@iwko
Copy link
Contributor

@iwko iwko commented Feb 20, 2018

@XVincentX I went through /lib/rest/ and I am not sure I am able to find wrong exceptions. https://github.com/iwko/express-gateway/commit/a58efdcdbf373c6c7e9bec276d52e8a2e01fcce3 I did example commit and I am not sure if this is what you had in mind?

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 21, 2018

@iwko Not exactly that.

https://github.com/ExpressGateway/express-gateway/blob/master/lib/rest/routes/users.js#L8-L17

You can see here that, in case the schema validation fails, a generic error is returned using next(err). On the other hand, the end user should definitely know that the thing didn't go through because of a schema validation error.

Does that clarify the issue?

@iwko
Copy link
Contributor

@iwko iwko commented Feb 21, 2018

Okay, now I've got the point

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 21, 2018

If you need any clarification or help feel free to write me. There are some parts that might need to be refactored in order to make that happen; I can take care of those eventually.

@XVincentX XVincentX moved this from The eternal backlog to Working on in Technical debt Feb 22, 2018
@iwko
Copy link
Contributor

@iwko iwko commented Feb 24, 2018

@XVincentX I think I'm gonna pass on this issue. I've tried to figure out these codes but I am not sure which methods should have statuses added

@XVincentX
Copy link
Member Author

@XVincentX XVincentX commented Feb 24, 2018

That makes sense — it might be a bit complicated and tiring to do that. I'll handle it.

Thanks anyway!

@XVincentX XVincentX moved this from Working on to The eternal backlog in Technical debt Feb 26, 2018
@altsang altsang added this to Backlog in express-gateway Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.