Skip to content

chore: add linter enforcing static WithSourceErrorf format strings - #3248

Open
ivanauth wants to merge 1 commit into
authzed:mainfrom
ivanauth:fix/issue-2124-errorwithsourcef-static-string-lint
Open

chore: add linter enforcing static WithSourceErrorf format strings#3248
ivanauth wants to merge 1 commit into
authzed:mainfrom
ivanauth:fix/issue-2124-errorwithsourcef-static-string-lint

Conversation

@ivanauth

Copy link
Copy Markdown
Contributor

Fixes #2124

A dynamic string in the format position of dslNode.WithSourceErrorf is read as a format string, so any % it contains yields a malformed error. Adds a staticformatcheck analyzer (wired into the analyzers cmd/CI) requiring that argument to be a compile-time constant.

Follow-up: sibling dslNode.Errorf has the same issue, but the analyzer matches by name only, so covering it needs type-scoped matching (would else collide with fmt.Errorf et al.).

A dynamic string in the format position of dslNode.WithSourceErrorf is interpreted as a format string, so any '%' it contains produces a malformed error. The new staticformatcheck analyzer requires the format argument to be a compile-time constant.

Signed-off-by: ivanauth <ivan@authzed.com>
@ivanauth
ivanauth requested a review from a team as a code owner July 24, 2026 17:00
@github-actions github-actions Bot added the area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) Skip-Changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a linter for dslNode.ErrorWithSourcef that asserts that the second arg is a static string

1 participant