{"record":{"id":"5eca31815f89d169","repo":"kubernetes/kops","slug":"error-creating-temp-file-in-q-w","errorCode":null,"errorMessage":"error creating temp file in %q: %w","messagePattern":"error creating temp file in %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files.go","lineNumber":69,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc writeFileContents(destPath string, src Resource, fileMode os.FileMode) error {\n\tklog.Infof(\"Writing file %q\", destPath)\n\n\tin, err := src.Open()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error opening source resource for file %q: %v\", destPath, err)\n\t}\n\tdefer SafeClose(in)\n\n\tdir := filepath.Dir(destPath)\n\n\ttempFile, err := os.CreateTemp(dir, \".writefile\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating temp file in %q: %w\", dir, err)\n\t}\n\n\tcloseTempFile := true\n\tdeleteTempFile := true\n\tdefer func() {\n\t\tif closeTempFile {\n\t\t\tif err := tempFile.Close(); err != nil {\n\t\t\t\tklog.Warningf(\"error closing tempfile %q: %v\", tempFile.Name(), err)\n\t\t\t}\n\t\t}\n\t\tif deleteTempFile {\n\t\t\tif err := os.Remove(tempFile.Name()); err != nil {\n\t\t\t\tklog.Warningf(\"error removing tempfile %q: %v\", tempFile.Name(), err)\n\t\t\t}\n\t\t}\n\t}()\n\n\tif _, err := io.Copy(tempFile, in); err != nil {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files.go#L51-L87","documentation":"Thrown by writeFileContents when os.CreateTemp fails in the file's destination directory. Typically caused by the directory not existing at temp-file time, no writable permission on it, or exhaustion of inodes/files on the filesystem.","triggerScenarios":"Thrown at upup/pkg/fi/files.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the destination directory exists and is writable by the current user","Check disk/inode availability on the target filesystem","Ensure an earlier failure did not remove the directory between MkdirAll and CreateTemp"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}