Closed
Description
Describe the bug
Literal Scalar Parsing should not panic. Sending badly shaped data is a thing that Denial-Of-Service attackers like to do -- and being able to panic the thread this easy is a smell in my opinion.
To Reproduce
Steps to reproduce the behavior:
- Define a schema with a scalar String, Int, or Float type
- Query the schema with query literals which violate the contract in step (1)
- Notice that the thread panics
- Code reference here: https://github.com/graphql-rust/juniper/blob/master/juniper/src/parser/value.rs ... look for
parse_scalar_literal_by_infered_type
and then look for the panics.
Expected behavior
The framework should handle this class of error gracefully without a panic. It should return in this case a proper 400 Bad Request
HTTP Response with the standard graphql json error reporting array format: { "errors": [ "... must be an Int" ] }
Additional context
Violating the api shape is one of the easiest things a would-be denial-of-service attacker can try to attempt to crash your service and/or waste cpu cycles/compute resources/network resources.