Skip to content

[Code Quality] Type CompilerError.Type as an ErrorSeverity enum instead of raw string #50003

Description

@github-actions

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 ·

  • expires on Aug 4, 2026, 5:45 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions