Skip to content

Conversation

StevenACoffman
Copy link
Collaborator

@StevenACoffman StevenACoffman commented May 7, 2025

As reported by @hansod1 in github.com/99designs/gqlgen#3693
When in #291 we added the token limit, we should have used gqlerror to be more consistent
For reference, here is the change in gqlparser that added the new error.

As a result, the error is not as easy to detect as being from the parser because this part of the gqlgen codebase does not correctly interpret the token limit error as a parsing error because it is not returned from the parser as a *gqlerror.Error, and rather is an errors.errorString created with fmt.Errorf:

	doc, err := parser.ParseQueryWithTokenLimit(&ast.Source{Input: query}, e.parserTokenLimit)
	if err != nil {
		gqlErr, ok := err.(*gqlerror.Error)
		if ok {
			errcode.Set(gqlErr, errcode.ParseFailed)
			return nil, gqlerror.List{gqlErr}
		}
	}

We should add a lint rule that bans fmt.Errorf and adds nolint comments for our remaining uses in our panics but I only got 3 hours of sleep so not doing that now.

Signed-off-by: Steve Coffman steve@khanacademy.org

Signed-off-by: Steve Coffman <steve@khanacademy.org>
@coveralls
Copy link

Coverage Status

coverage: 87.649%. remained the same
when pulling 43bf1f2 on parser_limit_error
into fbff6f2 on master.

@StevenACoffman StevenACoffman merged commit 338ee49 into master May 7, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants