-
Notifications
You must be signed in to change notification settings - Fork 308
public.json should 404 when participant is unknown #479
Comments
I'd like to rush ahead with this one so I can implement the following functionality into Gittip Everywhere: if(user 404's on gittip) don't show Gittip button (unless on GitHub/Twitter) |
@clone1018 Go ahead and assign it to yourself so we know you're working on it. Any questions I can answer? |
Oh, I didn't mean to say I'd work on it, although I can if you're up for fixing what I break :P |
@clone1018 I am definitely up for fixing what you break. :-) |
This got me thinking, what's the appropriate thing to return in the case of 404 for json? Currently, if you raise Response(404), you'll get back HTML, but in this case since we're requesting json, it would be more appropriate to return a json-formatted response, say:
For other resources, it may also make sense to include other bits of information (such as validation?) in the error. |
Just so you guys know, I'll be super busy over the next couple of days and won't have time for this, sorry! |
Here's my basic return format for an API error:
The
|
I've never seen the |
@joonas Yeah, there's a ticket in Aspen to make it easier to return errors with different mimetypes: https://github.com/zetaweb/aspen/issues/19. If you'd like to work on it let me know and I'll add you to the Aspen team as well so you can assign it to yourself. |
@whit537 I can take a look at the code and decide then whether I should work on it or leave it to someone more knowledgeable ;) So don't add me yet, I'll let you know when I've had a chance to take a look at the relevant code |
This would actually be a good first ticket to work on in Aspen. There's a function that resolves those error pages, and we just need to compute the extension to use instead of hard-wiring '.html'. |
I assigned this to myself, but I haven't began work on it other than to verify that the issue is upstream in Aspen. @joonas, if you want it, go for it. I'll unassign myself for the moment, and check back later. |
@sigmavirus24 I originally got the idea from Namecheap's API. They use an encoding system though, whereas I prefer to have the name of the error itself to be descriptive. I think that's just my desire to be more idiomatic in my code - I wouldn't have You're correct on using 422 vs. 400, upon my reviewing the spec. I do see utility in providing errors in the return, beyond the HTTP code. For example, if two parameters are mutually exclusive, then specifying both is syntactically correct and can be understood by the server (hence, 400 is not correct), but make no semantic sense (so return a 422). Providing an API Error in the response could specify specifically what fields are causing the conflict, potentially greatly helping a developer trying to figure out why the 422 was returned. |
I don't disagree that it is a good idea, I would just love a clever way to be as explicit about it as possible. I dealt unfortunately directly with AWS (because using boto was overkill) and their error messages had types like that but were not even close to being helpful in my effort to debug the issue. So I guess having dealt with GitHub's API (mostly) and having not seen them there (and having had a good experience with it) contrasted with AWS (where I had a poor experience and limited exposure). But yeah, if some explicit errors can be given with descriptive messages, I'm all for it. And I didn't mean to sound pretentious in bringing up 422 (as I realize now I might have sounded). Sorry if it came across that way. Edit Also, me no speak good english while doing homework. (Sorry if the above seems jumbled) |
I stumbled upon this again as I was going through the errors on Sentry, and thus I thought it would be appropriate to address this. So picking up from the previous discussion, what would be the most appropriate course of action here? Return a 404 response with the body containing some JSON with key value pairs explaining the error state? Currently this is generating 500 errors, which is obviously less than desirable. |
This should be a 404. We have a ticket in Aspen to make media types of error pages match the file extension. Or if we don't, we should. |
I don't know if this can be closed, but it is returning a 404 response code, along with a HTML for the 404 error. |
Right now it gives {"receiving": "0.00"}.
The text was updated successfully, but these errors were encountered: