{"record":{"id":"532375b58ae5b79d","repo":"derailed/k9s","slug":"plugin-unmarshal-failed-for-s-w","errorCode":null,"errorMessage":"plugin unmarshal failed for %s: %w","messagePattern":"plugin unmarshal failed for (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/plugin.go","lineNumber":174,"sourceCode":"\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 {\n\t\t\treturn fmt.Errorf(\"plugin unmarshal failed for %s: %w\", path, err)\n\t\t}\n\t\tfor k := range oo.Plugins {\n\t\t\tplug := oo.Plugins[k]\n\t\t\tif err := plug.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"plugin %q validation failed for %s: %w\", k, path, err)\n\t\t\t}\n\t\t\tp.Plugins[k] = plug\n\t\t}\n\tcase json.PluginMultiSchema:","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/config/plugin.go#L156-L192","documentation":"After schema validation succeeds for the single-plugin shape (json.PluginSchema), Plugins.load yaml.Unmarshals the bytes into the Plugin struct (internal/config/plugin.go:171-173). This error wraps a YAML decode/type failure specific to that struct.","triggerScenarios":"YAML that passes the JSON-schema check but still fails decoding into Plugin: duplicate YAML keys, tab indentation errors, unexpected anchors/aliases, or scalars that cannot coerce into the string/bool fields (e.g. `dangerous: yes-please`). Note this path uses yaml.Unmarshal (not the KnownFields decoder built at plugin.go:168-169), so unknown fields alone do not trigger it.","commonSituations":"Hand-edited plugin files with tabs instead of spaces; copy-paste from websites introducing smart quotes or duplicate keys; YAML anchors left over from templating.","solutions":["Run the file through a YAML linter (yamllint) or `python -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))' file.yml`","Fix indentation (spaces only), remove duplicate keys and smart quotes","Simplify: remove anchors/merge keys and inline the values","The wrapped error text names the YAML line/type at fault - read the %w tail"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Strict-decode a plugin file the way k9s nearly does (decoder with KnownFields)\n// to surface type/indent errors before launch.\nfunc StrictLint(path string) error {\n\tb, _ := os.ReadFile(path)\n\td := yaml.NewDecoder(bytes.NewReader(b))\n\td.KnownFields(true)\n\tvar o config.Plugin\n\treturn d.Decode(&o)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use spaces, never tabs, in plugin YAML","yamllint every plugin file in CI","Avoid anchors/merge keys in config consumed by Go yaml.v3"],"tags":["go","yaml","k9s","plugin","config","unmarshal"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}