{"record":{"id":"c023c6a54e81f667","repo":"golangci/golangci-lint","slug":"s-validate-w","errorCode":null,"errorMessage":"[%s] validate: %w","messagePattern":"\\[(.+?)\\] validate: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/config_verify.go","lineNumber":34,"sourceCode":"\n\tjsonsch \"github.com/golangci/golangci-lint/v2/jsonschema\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/exitcodes\"\n)\n\nfunc (c *configCommand) executeVerify(cmd *cobra.Command, _ []string) error {\n\tusedConfigFile := c.getUsedConfig()\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(\"Verifying the configuration file %q with the JSON Schema\", usedConfigFile)\n\n\terr := validateConfiguration(jsonsch.NextSchema, 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 validateConfiguration(schemaPath, targetFile string) error {\n\tcompiler := jsonschema.NewCompiler()\n\tcompiler.UseLoader(jsonsch.NewEmbedLoader())\n\tcompiler.DefaultDraft(jsonschema.Draft7)\n\n\t// The name is not us\n\tschema, err := compiler.Compile(schemaPath)\n\tif err != nil {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/config_verify.go#L16-L52","documentation":"In executeVerify, the configuration file is validated against a JSON Schema via validateConfiguration. If the returned error is NOT a *jsonschema.ValidationError (i.e. an unexpected, infrastructure-level failure), it is wrapped as \"[%s] validate: %w\" with the config file path. Actual schema violations are instead printed as detail output and reported separately.","triggerScenarios":"Running the config verify subcommand when validateConfiguration fails with a non-ValidationError — e.g. the embedded schema could not be compiled/applied, or the target file could not be read/decoded at all.","commonSituations":"Passing a file with an unsupported extension to verify; internal issue building the JSON Schema compiler; the schema asset is missing or corrupt in the installation.","solutions":["Read the wrapped %w error — it usually points to a file-open/decode or schema-compile problem also wrapped in this package","Verify the config file path passed to verify exists and has a supported extension (.yaml, .yml, .json, .toml)","Reinstall the binary if the embedded schema appears missing/corrupt","If the wrapped error IS a ValidationError, expect the separate message 'the configuration contains invalid elements' instead — fix the flagged config keys"],"exampleFix":"// before\n$ golangci-lint config verify ./nonexistent.yml\n// [./nonexistent.yml] validate: open ./nonexistent.yml: no such file or directory\n\n// after\n$ golangci-lint config verify .golangci.yml","handlingStrategy":"type-guard","validationCode":"info, err := os.Stat(usedConfigFile)\nif err != nil {\n    return fmt.Errorf(\"config file %s must exist before verify: %w\", usedConfigFile, err)\n}\nswitch strings.ToLower(filepath.Ext(usedConfigFile)) {\ncase \".yaml\", \".yml\", \".json\", \".toml\":\ndefault:\n    return fmt.Errorf(\"unsupported config extension %s\", filepath.Ext(usedConfigFile))\n}","typeGuard":"func isSchemaValidationError(err error) bool {\n    var v *jsonschema.ValidationError\n    return errors.As(err, &v)\n}","tryCatchPattern":"if err := validateConfiguration(jsonsch.NextSchema, usedConfigFile); err != nil {\n    var v *jsonschema.ValidationError\n    if !errors.As(err, &v) {\n        return fmt.Errorf(\"[%s] validate: %w\", usedConfigFile, err) // infra failure, not user config\n    }\n    printValidationDetail(cmd, v.DetailedOutput())\n    return errors.New(\"the configuration contains invalid elements\")\n}","preventionTips":["Confirm the config file path and extension before running verify","Distinguish ValidationError (fix your config) from other errors (tool/file problem)","Reinstall the binary if verify fails with non-schema errors repeatedly","Run verify in CI to catch config drift early"],"tags":["json-schema","config","validation"],"backgroundTag":"config-schema-validate-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}