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

REST: Difficult to debug scenarios with malformed headers #1229

Closed
lukebakken opened this issue Oct 22, 2017 · 5 comments
Closed

REST: Difficult to debug scenarios with malformed headers #1229

lukebakken opened this issue Oct 22, 2017 · 5 comments

Comments

@lukebakken
Copy link
Contributor

This code swallows the exception from cowboy_req:parse_header and returns a generic 415 response. In my case, this is the exception detail that I saw via tracing:

% cowboy_req:parse_header/2 -> {exit,
                                   {request_error,
                                       {header,<<"content-type">>},
                                       'Malformed header. Please consult the relevant specification.'}}

I did a quick search to see if it's acceptable to return a body with a 415 response but couldn't find information about that. So, I'm wondering if including a text/plain body in the above scenario would be appropriate:

Malformed header "content-type". Please consult the relevant specification.

If you're curious, this is the header that caused the exception:

<<"content-type">> => <<"application/json;charset=UTF-8, application/json">>

I'm using Cowboy 2.0. Thanks!

@essen essen changed the title Difficult to debug scenarios with malformed headers REST: Difficult to debug scenarios with malformed headers Oct 22, 2017
@essen
Copy link
Member

essen commented Oct 22, 2017

Are you sure the 415 isn't enough here? It means the media type is not supported, and indeed this media type is not valid and therefore not supported. If you get a 415 all you gotta check is the content-type header you sent, it should be straightforward.

@michaelklishin
Copy link

In this specific case, perhaps. Providing more info one way or another would be appreciated (e.g. logging at debug level?).

@essen
Copy link
Member

essen commented Oct 22, 2017

Not much point doing extra logging when we have tracing. I do have plans for an integrated tracing solution for debugging purposes though (will become work on that this or next week I think).

@lukebakken
Copy link
Contributor Author

I'll leave this one up to you. I didn't find this straightforward but that's probably due to my unfamiliarity with cowboy.

@essen
Copy link
Member

essen commented Oct 3, 2019

This is probably best handled at this time via cowboy_tracer_h (I'll document it in 2.7) and later on via #1336 when implemented. Since there's a corresponding ticket with more details I'll close this. Thanks!

@essen essen closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants