golangci/golangci-lint-action

Failed at `config verify`

MeCode4Food opened this issue ยท 11 comments

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Description of the problem

config verify command failed with message, even though action has passed previously.

Message:

Error: Failed to run: Error: Command failed: /home/runner/golangci-lint-1.57.2-linux-amd64/golangci-lint config verify
jsonschema: "issues.exclude-files" does not validate with "/properties/issues/properties/exclude-files/type": expected array, but got null
jsonschema: "run" does not validate with "/properties/run/additionalProperties": additionalProperties 'print-resources-usage' not allowed
Error: the configuration contains invalid elements
Usage:
  golangci-lint config verify [flags]

Global Flags:
      --color string   Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
  -c, --config PATH    Read config from file path PATH
  -h, --help           Help for a command
      --no-config      Don't read config file
  -v, --verbose        Verbose output

Failed executing command with error: the configuration contains invalid elements
, Error: Command failed: /home/runner/golangci-lint-1.57.2-linux-amd64/golangci-lint config verify
jsonschema: "issues.exclude-files" does not validate with "/properties/issues/properties/exclude-files/type": expected array, but got null
jsonschema: "run" does not validate with "/properties/run/additionalProperties": additionalProperties 'print-resources-usage' not allowed
Error: the configuration contains invalid elements

Version of golangci-lint

v1.57.2

Version of the GitHub Action

undefined

Workflow file

name: Linter
on:
  push:
    branches:
      - master
  pull_request:

permissions:
  contents: read

jobs:
  golangci:
    name: Golang-CI
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v6
        with:
          version: v1.57.2

Go version

1.22.1

ldez commented

@pulkitanz This is not a compilation failure.

Since v6.5.0, the configuration is verified against JSONSchema by default.

@MeCode4Food The logs say you have invalid elements inside your configuration file.

jsonschema: "issues.exclude-files" does not validate with "/properties/issues/properties/exclude-files/type": expected array, but got null
jsonschema: "run" does not validate with "/properties/run/additionalProperties": additionalProperties 'print-resources-usage' not allowed
Error: the configuration contains invalid elements

Please provide your configuration file.

Note: using none to fill the issue template is a bad practice please avoid that.

ldez commented

To provide more information: the JSONSchema used to validate your configuration depends on the version of golangci-lint you are using.
In this case, this is v1.57.

Also note that v1.57.2 is very old: 2024-03-28
The latest version is v1.64.5.

go1.22.1 is also an old version with security issues, the Go team maintains only the 2 latest minor versions of Go: currently go1.23, go1.24

Removed all details tag with none

@ldez Thank you for responding. As it turns out, the message itself shows what is wrong with the configuration and what needs to be changed. Apologies for the bad Issue

ldez commented

You should not remove the details with "none" but you should provide them or at least provide an explanation: the fields are required.

Anyway, the question is answered.

That is fair.

I'd like to also talk about the added verification step in v6.5.0. As this has the ability to break existing builds, I do not think that this should be a minor version release.

ldez commented

As this has the ability to break existing builds, I do not think that this should be a minor version release.

Theoretically, everybody should use a valid configuration, so IMHO it doesn't require a major version of the GitHub Action.

This validation is important for the future v2 of golangci-lint: the migration command will migrate valid fields only.

If you want to disable this validation you can disable it but I strongly discourage doing that: https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#verify

You can run locally the validation of the configuration file:

golangci-lint config verify

Also, most of the IDEs are validating the configuration file by default.

JPig commented

This is actually a breaking change and should of been a major with the way it was implemented, for it to conform to a minor version update it would of had to have been done with verify defaulting to false, as the config validation logic is new functionality to the action that was never previously enforced to be passing.

You can argue that people should in theory have valid configurations, but that is not always guaranteed to be the case.

**we have had a number of our CI pipelines broken by this change for reference.

I agree, I think default to false should be a good compromise, which that flag to be set to true in the next major release

ldez commented

we have had a number of our CI pipelines broken by this change for reference.

I did what I thought was the best for users.
I do my best to please everybody but it's impossible.

I work full-time on golangci-lint and I have $100 as revenue, so be sure I didn't make this change to have more stress.

Companies appreciate using golangci-lint, and are quick to complain of free work, but as far as I know, they don't support us.
golangci/golangci-lint#5300 (comment)

JPig commented

Sorry, It wasn't intended to come across as a complaint, more-so just outlining how it is indeed a breaking change/major worthy version bump, instead of a minor, in the attempt to aid in any potential future scenarios where a decision like this around implementation or version number changes come into consideration.

ldez commented

Don't worry the integration of the v2 will be introduced with a major version of the GitHub Action.