{"record":{"id":"8db6b2fb51ed92a6","repo":"golangci/golangci-lint","slug":"error-in-config-of-rule-q-w","errorCode":null,"errorMessage":"error in config of rule %q: %w","messagePattern":"error in config of rule %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/revive/revive.go","lineNumber":203,"sourceCode":"\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\"\n\n\trawRoot := map[string]any{\n\t\t\"confidence\":         cfg.Confidence,\n\t\tseverity:             cfg.Severity,\n\t\t\"errorCode\":          cfg.ErrorCode,\n\t\t\"warningCode\":        cfg.WarningCode,\n\t\t\"enableAllRules\":     cfg.EnableAllRules,\n\t\t\"enableDefaultRules\": cfg.EnableDefaultRules,\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/revive/revive.go#L185-L221","documentation":"After the revive TOML config is decoded, getConfig iterates every configured rule and calls r.Initialize() to build the rule instance. This error is returned when a specific revive rule fails to initialize, most often because its arguments are invalid (wrong count, wrong type, or unsupported value). The rule name is embedded with %q and the Initialize error is wrapped with %w.","triggerScenarios":"Running golangci-lint with revive enabled when conf.Rules contains a rule whose Initialize() returns an error: bad arguments in the revive rules section (e.g. var-naming with non-string parameters), an unknown rule name carrying a config, or a required argument not supplied.","commonSituations":"Misspelled rule names or wrong-shaped arguments under linters-settings.revive.rules in .golangci.yml; copying rule config from outdated revive docs; enabling a rule with arguments incompatible after a revive upgrade.","solutions":["Read the wrapped cause: it names the offending rule in quotes; check that rule's expected arguments in the revive documentation.","Fix the arguments list for that rule in .golangci.yml (correct count and types).","Disable (enabled: false) or remove the misconfigured rule to unblock the run, then re-add a corrected config.","Verify the rule name exists in the revive version bundled with your golangci-lint release.","Isolate the failure by enabling one rule at a time with a minimal config."],"exampleFix":"// before (.golangci.yml)\nlinters-settings:\n  revive:\n    rules:\n      - name: line-length-limit\n        arguments: \"120\"\n// after\nlinters-settings:\n  revive:\n    rules:\n      - name: line-length-limit\n        arguments: [120]","handlingStrategy":"validation","validationCode":"// Check that each configured revive rule name is known before running\nvar knownReviveRules = map[string]bool{\n\t\"var-naming\": true, \"line-length-limit\": true, \"unexported-return\": true,\n}\n\nfunc validateReviveRules(rules []string) error {\n\tfor _, name := range rules {\n\t\tif !knownReviveRules[name] {\n\t\t\treturn fmt.Errorf(\"unknown revive rule %q\", name)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n\tif strings.Contains(err.Error(), \"error in config of rule\") {\n\t\t// extract the quoted rule name and fix its arguments in .golangci.yml\n\t\treturn fmt.Errorf(\"fix revive rule config: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Cross-check every rule name under linters-settings.revive.rules against the revive rule list for your golangci-lint version.","Pass arguments as a list with correct types (ints for limits, strings for names).","Enable one rule at a time when adding new rules to isolate failures.","Remove deprecated rules after upgrading golangci-lint."],"tags":["golang","configuration","revive","rule-initialization"],"backgroundTag":"rule-initialization-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}