{"record":{"id":"4691900714acdc04","repo":"golangci/golangci-lint","slug":"compile-schema-w","errorCode":null,"errorMessage":"compile schema: %w","messagePattern":"compile schema: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/config_verify.go","lineNumber":53,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"compile schema: %w\", err)\n\t}\n\n\tvar m any\n\n\tswitch strings.ToLower(filepath.Ext(targetFile)) {\n\tcase \".yaml\", \".yml\", \".json\":\n\t\tm, err = decodeYamlFile(targetFile)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\tcase \".toml\":\n\t\tm, err = decodeTomlFile(targetFile)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\tdefault:","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/config_verify.go#L35-L71","documentation":"validateConfiguration builds a jsonschema compiler with the embedded loader (jsonsch.NewEmbedLoader) and Draft7, then compiles the bundled schema with compiler.Compile(schemaPath). Any failure to load/compile the schema itself is wrapped as \"compile schema: %w\" — this indicates a problem with the schema, not the user's config.","triggerScenarios":"compiler.Compile(schemaPath) fails because the embedded schema resource cannot be located, parsed, or is invalid Draft7 JSON Schema.","commonSituations":"Corrupted or stripped binary where embedded assets (go:embed) are missing; an internal bug after a schema upgrade; running a modified/patched build lacking the embedded jsonschema files.","solutions":["Rebuild/reinstall the binary from a clean checkout so the go:embed'ed schema assets are present","Check the wrapped %w error for the schema path/resource that failed to load","Update to the latest release — schema compile failures are usually tool-internal and fixed upstream","If patching, validate the embedded schema JSON is valid Draft7 and reachable at schemaPath"],"exampleFix":"// before (custom build with stripped embed)\n// go build -tags noembed ./...  ->  compile schema: open jsonschema/schema.json: file does not exist\n\n// after\n// keep embed directives intact and build normally\ngo build ./cmd/golangci-lint","handlingStrategy":"fallback","validationCode":"// preflight: ensure the embedded schema resource is present\nif _, err := fs.ReadFile(embeddedFS, schemaPath); err != nil {\n    return fmt.Errorf(\"schema asset missing from build at %s: %w\", schemaPath, err)\n}","typeGuard":"func isSchemaCompileError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"compile schema\")\n}","tryCatchPattern":"schema, err := compiler.Compile(schemaPath)\nif err != nil {\n    if isSchemaCompileError(err) {\n        return fmt.Errorf(\"tool build appears corrupted (schema won't compile): %w — reinstall the binary\", err)\n    }\n    return fmt.Errorf(\"compile schema: %w\", err)\n}","preventionTips":["Build with standard tooling so go:embed assets are included; avoid stripped/custom tags","Reinstall from an official release if schema compilation fails","Keep the tool updated — schema changes ship with releases","Never modify the embedded schema JSON without validating it as Draft7"],"tags":["json-schema","tooling","embedded-assets"],"backgroundTag":"schema-compile-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}