{"record":{"id":"702964fc3f14f179","repo":"golangci/golangci-lint","slug":"failed-to-decode-configuration-w","errorCode":null,"errorMessage":"failed to decode configuration: %w","messagePattern":"failed to decode configuration: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/revive/revive.go","lineNumber":194,"sourceCode":"func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {\n\tconf := defaultConfig()\n\n\t// Since the Go version is dynamic, this value must be neutralized in order to compare with a \"zero value\" of the configuration structure.\n\tzero := &config.ReviveSettings{Go: cfg.Go}\n\n\tif !reflect.DeepEqual(cfg, zero) {\n\t\trawRoot := createConfigMap(cfg)\n\t\tbuf := bytes.NewBuffer(nil)\n\n\t\terr := toml.NewEncoder(buf).Encode(rawRoot)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to encode configuration: %w\", err)\n\t\t}\n\n\t\tconf = &lint.Config{}\n\t\t_, err = toml.NewDecoder(buf).Decode(conf)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to decode configuration: %w\", err)\n\t\t}\n\t}\n\n\tnormalizeConfig(conf)\n\n\tfor k, r := range conf.Rules {\n\t\terr := r.Initialize()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error in config of rule %q: %w\", k, err)\n\t\t}\n\t\tconf.Rules[k] = r\n\t}\n\n\treturn conf, nil\n}\n\nfunc createConfigMap(cfg *config.ReviveSettings) map[string]any {\n\tconst severity = \"severity\"","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/revive/revive.go#L176-L212","documentation":"golangci-lint's revive wrapper decodes a serialized TOML configuration buffer into a lint.Config struct inside getConfig. This error is returned when toml.NewDecoder(buf).Decode(conf) fails, meaning the configuration handed to revive is syntactically invalid TOML or does not match the expected config structure. The underlying decode error is wrapped with %w, so the root cause (line/column or field type mismatch) is preserved in the message.","triggerScenarios":"Calling newWrapper for the revive linter when the config buffer passed to toml.NewDecoder(buf).Decode(conf) cannot be parsed: malformed TOML syntax, unknown fields, or wrongly-typed values in the revive config section.","commonSituations":"Invalid TOML in the revive settings block of .golangci.yml (bad indentation, unquoted strings); assigning a scalar where revive expects a map or arguments list; an embedded config format change after upgrading golangci-lint.","solutions":["Inspect the wrapped cause after 'failed to decode configuration:' for the exact TOML line/column or type mismatch.","Fix keys and value types in the revive settings block so they match revive's expected config (rules as a list/map, arguments as lists).","Quote all TOML string values and fix indentation/tabs; validate the TOML with a linter such as taplo.","Temporarily remove the revive settings block to confirm it is the source, then re-add entries incrementally.","If it occurs with a stock config after an upgrade, pin the previous golangci-lint version and check for a regression."],"exampleFix":"// before (.golangci.yml revive section, invalid TOML value)\nlinters-settings:\n  revive:\n    rules:\n      var-naming: package-should-not-be-underlined\n// after\nlinters-settings:\n  revive:\n    rules:\n      - name: var-naming\n        arguments: [\"package-should-not-be-underlined\"]","handlingStrategy":"validation","validationCode":"// Validate revive TOML config before running the linter\nimport \"github.com/BurntSushi/toml\"\n\nfunc validateReviveConfig(raw string) error {\n\tvar cfg map[string]any\n\tif _, err := toml.Decode(raw, &cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid revive TOML config: %w\", err)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"conf, err := getConfig(...)\nif err != nil {\n\tvar parseErr toml.ParseError\n\tif errors.As(err, &parseErr) {\n\t\tlog.Fatalf(\"revive config TOML invalid: %v\", err)\n\t}\n\treturn fmt.Errorf(\"revive config error: %w\", err)\n}","preventionTips":["Validate the revive settings block with a YAML/TOML schema linter before committing.","Keep revive rule argument shapes matched to the revive docs for your golangci-lint version.","After upgrading golangci-lint, run a smoke lint on a minimal config first.","Quote all string values in TOML and avoid tabs."],"tags":["golang","toml","configuration","revive","decoding"],"backgroundTag":"config-decode-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}