{"record":{"id":"8c3748b7b2987f49","repo":"golangci/golangci-lint","slug":"decoding-configuration-file-w","errorCode":null,"errorMessage":"decoding configuration file: %w","messagePattern":"decoding configuration file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/internal/migrate/fakeloader/fakeloader.go","lineNumber":44,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\t// NOTE: this is inspired by viper internals.\n\tcc := &mapstructure.DecoderConfig{\n\t\tResult:           old,\n\t\tWeaklyTypedInput: true,\n\t\tDecodeHook:       config.DecodeHookFunc(),\n\t}\n\n\tdecoder, err := mapstructure.NewDecoder(cc)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"constructing mapstructure decoder: %w\", err)\n\t}\n\n\terr = decoder.Decode(raw)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"decoding configuration file: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":26,"sourceCodeEnd":49,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/internal/migrate/fakeloader/fakeloader.go#L26-L49","documentation":"Load wraps errors from decoder.Decode(raw), which converts the parsed raw map into the configuration struct. Because the fakeloader exists to preserve original key casing for linter configuration, this fires when the configuration file's content does not match the expected configuration schema or types.","triggerScenarios":"decoder.Decode(raw) fails: wrong value types (string where int expected), unknown/mistyped keys rejected by the hook, or a structurally invalid config map produced by an earlier parse step.","commonSituations":"A .golangci.yml with malformed settings, values of the wrong type (e.g. `linters: true` instead of a mapping), leftover keys from an older golangci-lint version, or hand-edited config typos.","solutions":["Read the wrapped message: it names the offending key/type — fix that field in the config file.","Run `golangci-lint migrate` or `golangci-lint config verify` against a JSON-schema-validated editor setup.","Remove or update deprecated settings from older golangci-lint versions before migrating.","Test with a minimal config and re-add sections until the failing key is isolated."],"exampleFix":"// before (.golangci.yml)\nlinters:\n  enable: gocritic\n// after\nlinters:\n  enable:\n    - gocritic","handlingStrategy":"validation","validationCode":"// validate config against the golangci-lint JSON schema before loading\n// golangci-lint config verify\n// or in CI:\n//   curl -sSf https://golangci-lint.run/ schema.json && ajv validate -s schema.json .golangci.yml","typeGuard":null,"tryCatchPattern":"if err := fakeloader.Load(srcPath, &old); err != nil {\n    var derr *mapstructure.Error\n    if errors.As(err, &derr) {\n        for _, e := range derr.Errors { log.Printf(\"bad config key: %s\", e) }\n    }\n    return err\n}","preventionTips":["Run `golangci-lint config verify` in CI.","Enable JSON-schema validation in your editor for .golangci.yml.","Avoid hand-editing types; use schema-aware completion.","Migrate deprecated keys with `golangci-lint migrate`."],"tags":["go","config","mapstructure","schema"],"backgroundTag":"config-decode-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}