{"record":{"id":"a74ce36b9cee7caa","repo":"ahmetb/kubectx","slug":"failed-to-write-temp-kubeconfig-w-a74ce3","errorCode":null,"errorMessage":"failed to write temp kubeconfig: %w","messagePattern":"failed to write temp kubeconfig: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/shell_session.go","lineNumber":89,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif cleanup != nil {\n\t\t\tdefer cleanup()\n\t\t}\n\t}\n\n\t// Write kubeconfig to temp file.\n\ttmpFile, err := os.CreateTemp(\"\", \"kubectx-shell-*.yaml\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temp kubeconfig file: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()\n\tdefer os.Remove(tmpPath)\n\n\tif _, err := tmpFile.Write(data); err != nil {\n\t\ttmpFile.Close()\n\t\treturn fmt.Errorf(\"failed to write temp kubeconfig: %w\", err)\n\t}\n\ttmpFile.Close()\n\n\t// Print entry message.\n\ts.printEntry(stderr, s.target)\n\n\t// Detect and start shell.\n\tshellBin := detectShell()\n\tcmd := exec.Command(shellBin)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\tcmd.Env = append(os.Environ(),\n\t\tappend([]string{\n\t\t\t\"KUBECONFIG=\" + tmpPath,\n\t\t\tenv.EnvIsolatedShell + \"=1\",\n\t\t}, s.extraEnv...)...,\n\t)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/shell_session.go#L71-L107","documentation":"Writing the extracted kubeconfig bytes to the already-created temp file failed (tmpFile.Write). The file was created successfully, so this is a mid-write I/O failure: disk full or the file descriptor became invalid.","triggerScenarios":"Thrown at cmd/kubectx/shell_session.go:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Free space in the temp directory /tmp or TMPDIR","Check dmesg for I/O or filesystem errors on the temp mount","Retry after freeing space; the temp file is cleaned up automatically"],"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"}