{"record":{"id":"7fdfb0c29e3a087a","repo":"derailed/k9s","slug":"plugin-validation-failed-for-s-w","errorCode":null,"errorMessage":"plugin validation failed for %s: %w","messagePattern":"plugin validation failed for (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/plugin.go","lineNumber":164,"sourceCode":"\n\treturn errs\n}\n\nfunc (p *Plugins) load(path string) error {\n\tif _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {\n\t\treturn nil\n\t}\n\tbb, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tscheme, err := data.JSONValidator.ValidatePlugins(bb)\n\tif err != nil {\n\t\tslog.Warn(\"Plugin schema validation failed\",\n\t\t\tslogs.Path, path,\n\t\t\tslogs.Error, err,\n\t\t)\n\t\treturn fmt.Errorf(\"plugin validation failed for %s: %w\", path, err)\n\t}\n\n\td := yaml.NewDecoder(bytes.NewReader(bb))\n\td.KnownFields(true)\n\n\tswitch scheme {\n\tcase json.PluginSchema:\n\t\tvar o Plugin\n\t\tif err := yaml.Unmarshal(bb, &o); err != nil {\n\t\t\treturn fmt.Errorf(\"plugin unmarshal failed for %s: %w\", path, err)\n\t\t}\n\t\tif err := o.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"plugin validation failed for %s: %w\", path, err)\n\t\t}\n\t\tp.Plugins[strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))] = o\n\tcase json.PluginsSchema:\n\t\tvar oo Plugins\n\t\tif err := yaml.Unmarshal(bb, &oo); err != nil {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/config/plugin.go#L146-L182","documentation":"Plugins.load (internal/config/plugin.go:158-165) first runs the plugin file through data.JSONValidator.ValidatePlugins, which validates the document against k9s's bundled JSON schemas and detects which of the three supported shapes it is (plugin / plugins map / plugins list). This error wraps that schema failure with the offending file path; the raw validation detail is also logged as a slog.Warn with slogs.Path and slogs.Error.","triggerScenarios":"A plugin file whose top-level keys do not match any supported schema: unknown fields, missing required fields (shortCut, command, description), wrong types (scopes not a string list), or a document that mixes the single-plugin and map forms. It aborts before any yaml.Unmarshal of the plugin body runs.","commonSituations":"Upgrading k9s where the plugin schema gained/renamed required fields; typos in top-level keys (e.g. shortcut vs shortCut); using a plugin written for another tool or an older k9s version; extra XDG data-dir plugin files shipping with a distribution.","solutions":["Run k9s from a terminal and read the slog.Warn line immediately preceding the returned error - it carries the exact schema violation","Fix the file so it matches one of the three supported shapes: a single plugin object, a `plugins:` map keyed by name, or a `plugins:` list","Correct field names/casing (shortCut, command, description, scopes) against the bundled schema","If the file is not meant for k9s, remove it from the plugins directory ($XDG_CONFIG_HOME/k9s/plugins, XDG data dirs, or the context config path)"],"exampleFix":"# before (unknown key, missing shortCut)\nshortcut: e\ndescription: edit\ncommand: vim\n# after\nshortCut: e\ndescription: edit\ncommand: vim\n","handlingStrategy":"validation","validationCode":"// Smoke-test a plugin file before dropping it into k9s's config dirs:\n// it must parse as YAML and carry only known top-level keys.\nvar knownKeys = map[string]bool{\"shortCut\":true,\"description\":true,\"command\":true,\"scopes\":true,\"args\":true,\"override\":true,\"pipes\":true,\"confirm\":true,\"background\":true,\"dangerous\":true,\"overwriteOutput\":true,\"inputs\":true,\"plugins\":true}\n\nfunc LintPluginFile(path string) error {\n\tb, err := os.ReadFile(path)\n\tif err != nil { return err }\n\tvar m map[string]any\n\tif err := yaml.Unmarshal(b, &m); err != nil { return err }\n\tfor k := range m {\n\t\tif !knownKeys[k] { return fmt.Errorf(\"unknown key %q in %s\", k, path) }\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin plugin files to one of the three supported shapes: single plugin, plugins map, plugins list","Run k9s once from a terminal after every plugin edit and read the slog.Warn schema detail","Keep plugin files out of XDG data dirs until they lint clean"],"tags":["go","yaml","json-schema","k9s","plugin","config","validation"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}