Skip to content

[BUG] make lint fails locally due to invalid .golangci.yml configuration and outdated linter version panic #2406

@rakshaak29

Description

@rakshaak29

What happened

When running make lint or executing the testing suite locally under modern versions of Golang (Go 1.25+), the golangci-lint runner abruptly fails due to two independent issues:

  1. Viper configuration unmarshal failure

    • The .golangci.yml contains an invalid top-level field:
      version: "2"
    • Viper strictly expects structured maps/dictionaries and fails while unmarshaling this field.
    • This causes the following error:
      ERRO Can't read config: can't unmarshal config by viper: 1 error(s) decoding:
      * 'Version' expected a map, got 'string'
      
  2. AST parsing panic from outdated Go linter logic

    • After bypassing the config issue, the pinned golangci-lint@v1.51.2 binary still crashes.
    • The crash occurs because its AST engine is incompatible with modern Go compiler releases.
    • Panic source:
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis.analyzeRecursive...
      

What you expected to happen

Running make lint should correctly download a stable, compatible version of golangci-lint and statically inspect the codebase without abruptly crashing due to:

  • internal Viper configuration parsing failures
  • AST parsing panics on modern Go releases

How to reproduce the bug

  1. Ensure your local Go environment is Go 1.25.x or higher
  2. Clone the repository:
    git clone https://github.com/openkruise/kruise.git
    cd kruise
  3. Run:
    make lint

How to fix

1) Fix .golangci.yml

Remove the invalid field at the top of the file:

version: "2"

2) Update Makefile

Bump the GOLANGCI_LINT binary target on line 133 from:

v1.51.2

to a stable compatible release such as:

v1.61.0

Environment details

  • OS: Mac / Linux
  • Go Version: 1.25.6

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions