Skip to content
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

Merged
merged 2 commits into from
Jun 1, 2022

Conversation

davidby-influx
Copy link
Contributor

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

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
@davidby-influx davidby-influx self-assigned this Jun 1, 2022
@davidby-influx davidby-influx marked this pull request as ready for review June 1, 2022 21:08
Comment on lines +33 to +51
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")
}
}
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

@gwossum gwossum left a 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

@davidby-influx davidby-influx merged commit 8c9768c into master Jun 1, 2022
@davidby-influx davidby-influx deleted the DSB_bad_bytes_master branch June 1, 2022 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants