-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: replace unprintable and invalid characters in errors (#23387) #23395
Conversation
for i := range tests { | ||
f := makePrintable(tests[i].raw) | ||
require.True(t, models.ValidToken([]byte(f))) | ||
c := 0 | ||
nSeq := 0 | ||
for _, r := range f { | ||
if r == unPrintReplRune { | ||
c++ | ||
if c == 1 { | ||
nSeq++ | ||
} | ||
require.LessOrEqual(t, c, unPrintMaxReplRune, "too many repeated %c", unPrintReplRune) | ||
} else { | ||
c = 0 | ||
} | ||
} | ||
require.Equalf(t, tests[i].nSeq, nSeq, "wrong number of elided sequences of replacement characters") | ||
} | ||
} |
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.
I'd prefer a simpler and more robust test against an expected literal, but I won't hold it against a cherry pick
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.
You and @lesam both want literal comparisons, so I am now on that train for the future.
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.
Looks like the original
Replace unprintable and invalid characters with '?'
in logged errors. Truncate consecutive runs of them to
only 3 repeats of '?'
closes #23386
(cherry picked from commit 0ae0bd6)
closes #23389