*: add linter rule to disallow panic(fmt.Sprintf())#5834
Merged
annrpom merged 3 commits intocockroachdb:masterfrom Mar 12, 2026
Merged
*: add linter rule to disallow panic(fmt.Sprintf())#5834annrpom merged 3 commits intocockroachdb:masterfrom
annrpom merged 3 commits intocockroachdb:masterfrom
Conversation
Member
c03e87b to
41e97bb
Compare
Add a lint check that disallows panic(fmt.Sprintf(...)) in favor of panic(errors.AssertionFailedf(...)). Using errors.AssertionFailedf ensures panic messages are not redacted in CockroachDB logs and include proper stack traces. The rule supports a lint:ignore PanicFmtSprintf directive for cases where the pattern is intentionally retained. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
9d214a3 to
7034608
Compare
RaduBerinde
approved these changes
Mar 11, 2026
cockroachkvs/cockroachkvs_test.go
Outdated
| return buf.String() | ||
| default: | ||
| panic(fmt.Sprintf("unknown command: %s", td.Cmd)) | ||
| panic(errors.AssertionFailedf("unknown command: %s", td.Cmd)) |
Member
There was a problem hiding this comment.
Maybe you can ask Claude to change these kind of panics to t.Fatalf()
…(...)) Mechanically replace all instances of panic(fmt.Sprintf(...)) with panic(errors.AssertionFailedf(...)). The errors.AssertionFailedf function creates structured errors with stack traces, which is preferable to unstructured panic strings. This is a mechanical conversion with no changes to the panic arguments themselves. A follow-up commit wraps safe diagnostic arguments with errors.Safe() so they appear in redacted crash reports. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
…sh reports For panic messages using errors.AssertionFailedf, arguments are redacted by default in CockroachDB crash reports. Wrap safe diagnostic arguments (internal identifiers, counts, sizes, enum values) with errors.Safe() so they appear in redacted reports, while leaving user keys and values unwrapped to prevent PII leaks. Also add SafeFormat/String implementations for interleavePos, compactionKind, CompactionState, and vfs.OpType so these types are self-formatting as safe values. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
7034608 to
79201eb
Compare
Contributor
Author
|
TFTR! ('-')7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See individual commits for details.