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

Grape should log a warning when the formatter returns a 406 for an unsupported content type. #322

Closed
idyll opened this issue Jan 22, 2013 · 5 comments

Comments

@idyll
Copy link
Contributor

idyll commented Jan 22, 2013

Right now when an unsupported content type is passed as the request.media_type grape returns a 406.

I would be great if the media_type was logged along with the 406 status because when this happens in error it is really hard to debug.

@dblock dblock closed this as completed in c15809a Feb 9, 2013
@dblock
Copy link
Member

dblock commented Feb 9, 2013

Including the requested format and media type along in the body of the error. Let me know if this works.

@leods92
Copy link

leods92 commented Sep 11, 2014

This returns 'txt' even when format is 'xml' for example.
Is this expected behaviour?

@dblock
Copy link
Member

dblock commented Sep 11, 2014

@leods92 It wouldn't be. Error formats can be controlled separately though. Build a repro case?

@leods92
Copy link

leods92 commented Sep 12, 2014

@dblock
By creating a MyApi class with content_type :json, "application/json" in it, only json is allowed. Great.
Then, you can try accessing a resource with .xml extension for example and you'll get The requested format 'txt' is not supported.. This probably happens because Grape ignores input kind since it's not trying to parse it (because we didn't tell it to support other formats). When a user appends an extension, say .xml though, it's counter-intuitive to get that 'txt' message. I think that to fix this, we'd need to extract the extension from the URL. For a quick bugfix I'd just remove the format from the error message all together.
What do you think?

@dblock
Copy link
Member

dblock commented Sep 12, 2014

It does sound strange, some code that determines the format should settle on XML in this case, open another issue with maybe a spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants