base.api methods should send error messages that content type is invalid if they don't parse as JSON

RESOLVED FIXED

Status

Taskcluster
General
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: jhford, Unassigned)

Tracking

Details

Attachments

(1 attachment)

Pete hit this today and it was the bane of my existence while writing the python client.

Right now, the server only understands requests that are JSON and with the Content-type header set properly.  That said, its error message for any exceptional case is to say that JSON Schema validation failed and list which keys are missing.

When Pete was sending fully valid and well formed JSON data but missing the Content-type header.  The error he was getting was a JSON-Schema validation error.  I was sending the write header, but URL Encoded instead of JSON encoded.

Given that (aiui) all endpoints only understand JSON input, we should:

1. if Content-type is not an understood one, we should error out with a message of "Content-type ${type} is not understood"

2. if the request body does not parse as the specified content-type, we should 400 with a message of "Body of type ${type} does not parse as such"

This would be really helpful when hitting API endpoints or working on client libraries.
Agree... this sounds like a good idea.

We should reply 400, if content-type isn't application/json and an input schema is defined.
Component: TaskCluster → General
Product: Testing → Taskcluster
Created attachment 8693989 [details]
Github PR

Note, this is on top of the other PR...
Attachment #8693989 - Flags: review?(jhford)
Attachment #8693989 - Flags: review?(jhford) → review+
Landed... needs rolling out, but that is a slow process...
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.