fix(audits): incorrect status code range#145
Conversation
enisdenjo
left a comment
There was a problem hiding this comment.
Actually, as per the spec, the expected status code should be 400 for both content-types. Would you like to make the necessary changes?
application/json
https://graphql.github.io/graphql-over-http/draft/#sec-application-json.Examples.JSON-parsing-failure
application/graphql-response+json
https://graphql.github.io/graphql-over-http/draft/#sec-application-graphql-response-json.Examples.JSON-parsing-failure
|
Good point!
Code for 865D and 556Agraphql-http/src/audits/server.ts Lines 672 to 689 in a49c45b graphql-http/src/audits/server.ts Lines 690 to 706 in a49c45b For Code for B6DC and BCF8graphql-http/src/audits/server.ts Lines 559 to 572 in a49c45b graphql-http/src/audits/server.ts Lines 573 to 586 in a49c45b I would proceed like this: |
|
Historically we allowed 4XX which is why those cases exist, but are now obsolete.
Note that it should allow 2XX only when accepting application/json, not the new content type. Other than that, we're looking good. Thanks! |
9a425d7 to
5587c03
Compare
|
(woops, accidentally closed this by resetting my changes to keep working on them. Going to reopen in a few minutes). |
|
Finally found time to wrap things up. Out of the three proposed changes, I ultimately implemented numbers 2 and 3. Number 1 turned out to be unrelated to the other changes, because I mixed up document/query parsing failures and request body parsing failures. Here's a summary of the changes:
It's two separate commits, each referencing the relevant parts in the specs in the commit message body. Regarding |
426cc00 to
ec5c8c2
Compare
Relevant section: 6.4.2.1.1 JSON parsing failure https://graphql.github.io/graphql-over-http/draft/#sec-application-graphql-response-json.Examples.JSON-parsing-failure
ec5c8c2 to
4e9b409
Compare
enisdenjo
left a comment
There was a problem hiding this comment.
Great work, this is looking good! 🙏
This PR fixes the status code range assertion of audit check B6DC, which did not match the audit name/description.
graphql-http/src/audits/server.ts
Lines 559 to 572 in a49c45b
The name/description suggests 5xx status codes may be used. However, the audit function currently requires the status code to be between 400 and 499.