Skip to content

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

Closed

Description

@idyll

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.

Activity

  1. dblock commented on Feb 9, 2013

    @dblock
    Member

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

  2. leods92 commented on Sep 11, 2014

    @leods92

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

  3. dblock commented on Sep 11, 2014

    @dblock
    Member

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

  4. leods92 commented on Sep 12, 2014

    @leods92

    @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?

  5. dblock commented on Sep 12, 2014

    @dblock
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions