-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sweep: Better error message for invalid variables (jsonschema) #369
Comments
Here's the PR! #372.⚡ Sweep Free Trial: I used GPT-3.5 to create this ticket. You have 0 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.
Step 1: 🔍 Code SearchI found the following snippets in your repository. I will now analyze these snippets and come up with a plan. Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.graphql-go-tools/pkg/variablevalidator/variablevalidator.go Lines 1 to 125 in f787e7a
graphql-go-tools/pkg/graphql/request.go Lines 1 to 83 in f787e7a
Summaries of links found in the content: The page discusses the use of the https://github.com/qri-io/jsonschema: The page is about the The page is about JSON Schema, a declarative language used to annotate and validate JSON documents. It describes the benefits of using JSON Schema, such as providing clear human- and machine-readable documentation and validating data for automated testing and ensuring the quality of client-submitted data. The page also mentions the announcement and feedback solicitation for the JSON Schema specification process, including plans to publish the JSON Schema media types as an IETF RFC. It discusses the community activities, learning resources, and project status. Additionally, the page mentions the use of JSON Schema in the Step 2: 🧐 Snippet AnalysisFrom looking through the relevant snippets, I decided to make the following modifications:
Step 3: 📝 PlanningI have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request: Improve error messages for invalid variables (jsonschema)
Step 4: ⌨️ Coding
Step 5: 🔁 Code ReviewHere are the my self-reviews of my changes at Here is the 1st review
I finished incorporating these changes. To recreate the pull request, leave a comment prefixed with "sweep:" or edit the issue. |
@buger The inability for it to see the logs should be fixed now. |
sweep: Retry |
Let's gooo @buger |
Description
graphql-go-tools
is currently using qri-io/jsonschema: golang implementation of https://json-schema.org drafts 7 & 2019-09 (github.com) as jsonschema validation library.This library is based on paths which means that the error messages can be potentially unclear, e.g.:
If an error happens on the root of the variables object it prints:
/: type should be string, got null
if the error happens inside an object of the variables object it can look like this
/name: type should be string, got null
The
/
path does not really show which property is responsible for the error.Background
For variable validation
graphql-go-tools
is generating a partial jsonschema, e.g.:myString: String!
will be generated as{"type":"string"}
input myInput { myString: String }
will be generated as{"type":"object","properties":{"myString":{"type":["string","null"]}}}
A possible solution could be to use the
required
property from jsonschema to improve error messages which would require a change of jsonschema generation. Subjecto for research.Here is a snippet of what error message some automated tests expect to see when variables are invalid (
master
branch). And yeah, it's the same message for all cases:Extra properties in variables
,integer instead of string
,array instead of string
.Error while validating GraphQL request: \'Validation for variable \\"filter\\" failed: doesn\'t validate with \'/$defs/StringQueryOperatorInput\'
Changes should be made somewhere in https://github.com/TykTechnologies/graphql-go-tools/blob/master/pkg/variablevalidator/variablevalidator.go
The text was updated successfully, but these errors were encountered: