ParseQueryWithTokenLimit's error is not processed correctly by gqlgen · Issue #3693 · 99designs/gqlgen · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This concerns the token limit config option added last year: #3136
I was testing it and noticed that it doesn't send the correct error to the client 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}
}
}
Is there a deeper reason why this function isn't designed to return all errors out of ParseQueryWithTokenLimit and is instead only checking for *gqlerror.Error?
I am unsure why they didn't create a gqlerror over in the parser, but I suspect that's the right place to fix this. That being said, let me know if you'd accept a PR returning all errors, not just gqlerror, from ParseQueryWithTokenLimit and I'll submit it.
The text was updated successfully, but these errors were encountered:
I super appreciate your bringing it to my attention and your willingness to make a PR! Honestly, any PRs (here or in gqlparser) are always welcome as both are unpaid community led volunteer efforts.
Any error from gqlparser should always be a gqlerror, and we should really have added a linter to ban the fmt.Errorf and just sprinkle a few nolint comments for any of the parser's Panic locations where that might cause a cyclical dependency. If you are willing to add a PR to gqlparser for that, I would really appreciate it!
The gqlerror.List takes a set of *gqlerror.Error because so it can output them more nicely if it has the extra information that those can contain (like Location).
We are trying to frontload the coercion to *gqlerror.Error at the point of error Origination because at the point of error Reporting we will no longer have important contextual information (like Location) and such.
This concerns the token limit config option added last year: #3136
I was testing it and noticed that it doesn't send the correct error to the client 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 anerrors.errorString
created withfmt.Errorf
:For reference, here is the change in gqlparser that added the new error.
Is there a deeper reason why this function isn't designed to return all errors out of
ParseQueryWithTokenLimit
and is instead only checking for*gqlerror.Error
?I am unsure why they didn't create a
gqlerror
over in the parser, but I suspect that's the right place to fix this. That being said, let me know if you'd accept a PR returning all errors, not justgqlerror
, fromParseQueryWithTokenLimit
and I'll submit it.The text was updated successfully, but these errors were encountered: