{"record":{"id":"f07cfd30d18aecfd","repo":"ahmetb/kubectx","slug":"context-does-not-exist","errorCode":null,"errorMessage":"context does not exist","messagePattern":"context does not exist","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/delete.go","lineNumber":79,"sourceCode":"\tcur, err := kc.GetCurrentContext()\n\tif err != nil {\n\t\treturn deleteName, false, fmt.Errorf(\"failed to get current context: %w\", err)\n\t}\n\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":61,"sourceCodeEnd":90,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/delete.go#L61-L90","documentation":"Guard error in deleteContext: kc.ContextExists(name) reported that no context entry with the given name exists in any loaded kubeconfig file. This is the sentinel 'not found' path — the user asked to delete a context name that is not defined (typo, already deleted, or defined only in a file not covered by KUBECONFIG).","triggerScenarios":"Thrown at cmd/kubectx/delete.go:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run `kubectx` to list valid context names and retype the name","Check the KUBECONFIG env var if the context lives in another file"],"exampleFix":null,"handlingStrategy":"validation","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"}