-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add option to redact token details from parser error messages #3618
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
Conversation
@@ -1188,4 +1188,70 @@ triple3 : """edge cases \\""" "" " \\"" \\" edge cases""" | |||
"\"\t\" scalar A" | _ | |||
} | |||
|
|||
def "can redact tokens in InvalidSyntax parser error message"() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finding the right offending cases was the hard bit!
These tests cover the 3 message strings to be redacted
InvalidSyntax.full
InvalidSyntaxBail.full
InvalidSyntaxMoreTokens.full
|
||
defaultOperationOptions.getMaxTokens() == 15_000 | ||
defaultOperationOptions.getMaxWhitespaceTokens() == 200_000 | ||
defaultOperationOptions.isCaptureSourceLocation() | ||
!defaultOperationOptions.isCaptureLineComments() | ||
!defaultOperationOptions.isCaptureIgnoredChars() | ||
defaultOptions.isReaderTrackData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo from the past
|
||
defaultSdlOptions.getMaxCharacters() == Integer.MAX_VALUE | ||
defaultSdlOptions.getMaxTokens() == Integer.MAX_VALUE | ||
defaultSdlOptions.getMaxWhitespaceTokens() == Integer.MAX_VALUE | ||
defaultSdlOptions.isCaptureSourceLocation() | ||
defaultSdlOptions.isCaptureLineComments() | ||
!defaultSdlOptions.isCaptureIgnoredChars() | ||
defaultOptions.isReaderTrackData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo from the past
This looks good to me! |
@@ -189,6 +192,7 @@ public static void setDefaultSdlParserOptions(ParserOptions options) { | |||
private final int maxTokens; | |||
private final int maxWhitespaceTokens; | |||
private final int maxRuleDepth; | |||
private final boolean redactTokenParserErrorMessages; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaults to false - great
@@ -319,6 +332,7 @@ public static class Builder { | |||
private int maxTokens = MAX_QUERY_TOKENS; | |||
private int maxWhitespaceTokens = MAX_WHITESPACE_TOKENS; | |||
private int maxRuleDepth = MAX_RULE_DEPTH; | |||
private boolean redactTokenParserErrorMessages = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaulted to false - great!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one
@ee-usgs FYI I merged this PR into master. This will kick off a master build deployment, in case you want to test (of course, no obligation to do anything, you've given me very detailed info already!) Our master build versions contain the date in UTC and the git short hash in the name. Look for it in your favourite Maven website, this one is most up to date: https://repo1.maven.org/maven2/com/graphql-java/graphql-java/. It takes a short while to land in Maven, it'll land soon. Thanks again for the suggestion! |
Addresses #3617
Adds an option to redact the token from parser error messages. Note that the default behaviour will be the same as before, by default error messages provide token information if available, to assist with debugging.
There are three parsing messages to be redacted:
InvalidSyntax.full
InvalidSyntaxBail.full
InvalidSyntaxMoreTokens.full