{"record":{"id":"8918b9a7b4ae014a","repo":"golangci/golangci-lint","slug":"s-validate-w-8918b9","errorCode":null,"errorMessage":"[%s] validate: %w","messagePattern":"\\[(.+?)\\] validate: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/migrate.go","lineNumber":161,"sourceCode":"\t}\n\n\tif c.opts.skipValidation {\n\t\treturn nil\n\t}\n\n\tusedConfigFile := c.viper.ConfigFileUsed()\n\tif usedConfigFile == \"\" {\n\t\tc.log.Warnf(\"No config file detected\")\n\t\tos.Exit(exitcodes.NoConfigFileDetected)\n\t}\n\n\tc.log.Infof(\"Validating v1 configuration file: %s\", usedConfigFile)\n\n\terr := validateConfiguration(jsonsch.V1Schema, usedConfigFile)\n\tif err != nil {\n\t\tvar v *jsonschema.ValidationError\n\t\tif !errors.As(err, &v) {\n\t\t\treturn fmt.Errorf(\"[%s] validate: %w\", usedConfigFile, err)\n\t\t}\n\n\t\tprintValidationDetail(cmd, v.DetailedOutput())\n\n\t\treturn errors.New(\"the configuration contains invalid elements\")\n\t}\n\n\treturn nil\n}\n\nfunc (c *migrateCommand) persistentPreRunE(_ *cobra.Command, args []string) error {\n\tc.log.Infof(\"%s\", c.buildInfo.String())\n\n\tloader := config.NewBaseLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, c.opts.LoaderOptions, fakeloader.NewConfig(), args)\n\n\t// Loads the configuration just to get the effective path of the configuration.\n\terr := loader.Load()\n\tif err != nil {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/migrate.go#L143-L179","documentation":"During migrate's `preRunE`, the v1 configuration file is validated against the v1 JSON schema. If validation fails with an error that is NOT a jsonschema.ValidationError (i.e. an unexpected/non-schema failure such as an unreadable file), it is wrapped as `[%s] validate: %w`. Schema validation failures with details are instead printed and replaced by a generic message.","triggerScenarios":"Running migrate when the config file cannot be read/parsed by the validator for a non-schema reason — e.g. malformed YAML/JSON that the schema loader itself chokes on, a missing file, or an I/O error opening the config.","commonSituations":"Config file with syntax errors (bad indentation, tabs); file deleted between load and validation; permission issues reading the config; unusual encoding (BOM, non-UTF8).","solutions":["Fix the underlying error shown after this wrapper (often a YAML/JSON parse error).","Validate the config file syntax with a YAML/JSON linter before running migrate.","Ensure the config file exists and is readable by the current user.","Run `golangci-lint config verify` to get schema validation details."],"exampleFix":"# before (.golangci.yml with tabs)\nlinters:\n\tenable: [govet]\n# after (spaces)\nlinters:\n  enable:\n    - govet","handlingStrategy":"validation","validationCode":"// syntax-check the config as YAML before validating against the schema\nvar v any\nif err := yaml.Unmarshal(data, &v); err != nil {\n    return fmt.Errorf(\"invalid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := validateConfiguration(jsonsch.V1Schema, file)\nvar ve *jsonschema.ValidationError\nif err != nil && !errors.As(err, &ve) {\n    return fmt.Errorf(\"[%s] validate: %w\", file, err) // non-schema failure: fix syntax/IO first\n}","preventionTips":["Lint YAML/JSON config files in CI before running golangci-lint.","Avoid tabs in YAML; use spaces consistently.","Ensure the config file exists and is readable at the path passed to --config.","Use `golangci-lint config verify` as a pre-flight check."],"tags":["go","config","validation","yaml"],"backgroundTag":"invalid-config-value","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}