Description
pkg/console/console_types.go:13 declares Type string // "error", "warning", "info" — a stringly-typed field actively dispatched on in console.go:97 (switch) and set raw at ~6 construction sites (pkg/parser/schema_compiler.go:466, pkg/parser/import_error.go:135, pkg/cli/grant.go:276, etc.). A typo like "eror" silently falls through to the default branch with no compile-time protection.
Note: a prior issue (#39816) tracked this same finding but was closed as NOT_PLANNED without a code change — the duplication is still present in the codebase today, confirmed by typist re-detecting it in discussion #49984.
Suggested Changes
- Introduce
type ErrorSeverity string with ErrorSeverityError/ErrorSeverityWarning/ErrorSeverityInfo constants next to CompilerError in pkg/console/console_types.go
- Update the
CompilerError.Type field type
- Update all raw-string construction sites and the switch in
console.go to use the new constants
Files Affected
pkg/console/console_types.go
pkg/console/console.go
pkg/parser/schema_compiler.go
pkg/parser/import_error.go
pkg/cli/grant.go
Success Criteria
CompilerError.Type is ErrorSeverity, not string
- All construction/comparison sites use named constants
- No behavior change; existing tests pass
Source
Extracted from Typist - Go Type Consistency Analysis discussion #49984
Priority
Medium - prevents silent typo bugs in string comparisons. Estimated effort: < 1 hour.
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 88.4 AIC · ⌖ 4.01 AIC · ⊞ 10.3K · ◷
Description
pkg/console/console_types.go:13declaresType string // "error", "warning", "info"— a stringly-typed field actively dispatched on inconsole.go:97(switch) and set raw at ~6 construction sites (pkg/parser/schema_compiler.go:466,pkg/parser/import_error.go:135,pkg/cli/grant.go:276, etc.). A typo like"eror"silently falls through to the default branch with no compile-time protection.Note: a prior issue (#39816) tracked this same finding but was closed as NOT_PLANNED without a code change — the duplication is still present in the codebase today, confirmed by
typistre-detecting it in discussion #49984.Suggested Changes
type ErrorSeverity stringwithErrorSeverityError/ErrorSeverityWarning/ErrorSeverityInfoconstants next toCompilerErrorinpkg/console/console_types.goCompilerError.Typefield typeconsole.goto use the new constantsFiles Affected
pkg/console/console_types.gopkg/console/console.gopkg/parser/schema_compiler.gopkg/parser/import_error.gopkg/cli/grant.goSuccess Criteria
CompilerError.TypeisErrorSeverity, notstringSource
Extracted from Typist - Go Type Consistency Analysis discussion #49984
Priority
Medium - prevents silent typo bugs in string comparisons. Estimated effort: < 1 hour.