{"record":{"id":"8c9ee0f37aeacd1f","repo":"ahmetb/kubectx","slug":"failed-to-modify-yaml-doc-w","errorCode":null,"errorMessage":"failed to modify yaml doc: %w","messagePattern":"failed to modify yaml doc: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/delete.go","lineNumber":83,"sourceCode":"\t// resolve \".\" to a real name\n\tif name == \".\" {\n\t\tif cur == \"\" {\n\t\t\treturn deleteName, false, errors.New(\"can't use '.' as the no active context is set\")\n\t\t}\n\t\twasActiveContext = true\n\t\tname = cur\n\t}\n\n\texists, err := kc.ContextExists(name)\n\tif err != nil {\n\t\treturn name, false, fmt.Errorf(\"failed to check context: %w\", err)\n\t}\n\tif !exists {\n\t\treturn name, false, errors.New(\"context does not exist\")\n\t}\n\n\tif err := kc.DeleteContextEntry(name); err != nil {\n\t\treturn name, false, fmt.Errorf(\"failed to modify yaml doc: %w\", err)\n\t}\n\tif err := kc.Save(); err != nil {\n\t\treturn name, wasActiveContext, fmt.Errorf(\"failed to save modified kubeconfig file: %w\", err)\n\t}\n\treturn name, wasActiveContext, nil\n}\n","sourceCodeStart":65,"sourceCodeEnd":90,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/delete.go#L65-L90","documentation":"Wrapper error in deleteContext: kc.DeleteContextEntry(name) failed to remove the context's YAML node from the kubeconfig document (kyaml manipulation failure, e.g. malformed 'contexts' tree). The in-memory edit never happened; cause wrapped with %w.","triggerScenarios":"Thrown at cmd/kubectx/delete.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the kubeconfig 'contexts' section for structural problems","Back up and repair the kubeconfig, then retry the delete"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12ad6fb22e8c546ee2b54e7de38aa51c906832f7","analyzedAt":"2026-09-02T12:23:10.107Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}