{"record":{"id":"86e828caf3b938ab","repo":"golangci/golangci-lint","slug":"failed-to-calculate-config-salt-w","errorCode":null,"errorMessage":"failed to calculate config salt: %w","messagePattern":"failed to calculate config salt: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/run.go","lineNumber":633,"sourceCode":"\t\treturn fmt.Sprintf(\"%db\", memBytes)\n\t}\n\tif memBytes < Mb {\n\t\treturn fmt.Sprintf(\"%dkb\", memBytes/Kb)\n\t}\n\treturn fmt.Sprintf(\"%dmb\", memBytes/Mb)\n}\n\n// Related to cache.\n\nfunc initHashSalt(logger logutils.Log, version string, cfg *config.Config) error {\n\tbinSalt, err := computeBinarySalt(version)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to calculate binary salt: %w\", err)\n\t}\n\n\tconfigSalt, err := computeConfigSalt(cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to calculate config salt: %w\", err)\n\t}\n\n\tgoModSalt, err := computeGoModSalt()\n\tif err != nil {\n\t\t// NOTE: missing go.mod must be ignored.\n\t\tlogger.Warnf(\"Failed to calculate go.mod salt: %v\", err)\n\t}\n\n\tb := bytes.NewBuffer(binSalt)\n\tb.WriteString(\"golangci-lint-cache/v2\")\n\tb.Write(configSalt)\n\tb.WriteString(goModSalt)\n\n\tcache.SetSalt(b)\n\n\treturn nil\n}\n","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/run.go#L615-L651","documentation":"initHashSalt computes a config salt by serializing the parts of the config that affect analysis (Linters.Settings and Run.BuildTags). If that serialization fails, the error is wrapped as \"failed to calculate config salt\". Note the same underlying error text can also surface as error 118.","triggerScenarios":"computeConfigSalt returns an error, which per the implementation happens when yaml.Marshal of cfg.Linters.Settings fails — typically because the settings contain values that cannot be marshaled (unexpected types after programmatic config mutation).","commonSituations":"Custom builds or plugins that inject non-marshalable values into config.Linters.Settings; corrupted or programmatically-built config files; rarely, YAML library incompatibilities after upgrades.","solutions":["Validate your .golangci.yml (check the config schema against your golangci-lint version) and simplify exotic settings.","Run `golangci-lint config verify` to catch malformed configuration.","Bisect settings: comment out linter-settings blocks until the error disappears to find the offending entry.","Pin or upgrade golangci-lint to a version compatible with your config keys (deprecated keys may parse differently).","Clear the cache (`golangci-lint cache clean`) after fixing the config."],"exampleFix":"// before (.golangci.yml)\nlinters-settings:\n  gocyclo:\n    min-complexity: [not, a, number]\n// after\nlinters-settings:\n  gocyclo:\n    min-complexity: 15","handlingStrategy":"validation","validationCode":"// preflight: verify config before running\nif err := exec.Command(\"golangci-lint\", \"config\", \"verify\").Run(); err != nil {\n\treturn fmt.Errorf(\"invalid .golangci.yml; config salt computation will fail: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil && strings.Contains(err.Error(), \"failed to calculate config salt\") {\n\tlog.Fatalf(\"check linter settings in .golangci.yml (unmarshalable/mistyped values): %v\", err)\n}","preventionTips":["Run `golangci-lint config verify` in CI before the lint step.","Keep linter settings values correctly typed in .golangci.yml.","Bisect config blocks when a new setting breaks the run.","Clear the cache after config/schema upgrades."],"tags":["config","cache","yaml","golangci-lint"],"backgroundTag":"config-salt-computation-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}