{"record":{"id":"22e243ccd4cced5c","repo":"kubernetes/kops","slug":"error-writing-file-q-v-22e243","errorCode":null,"errorMessage":"error writing file %q: %v","messagePattern":"error writing file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files.go","lineNumber":88,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"error writing file %q: %v\", tempFile.Name(), err)\n\t}\n\n\tif err := tempFile.Chmod(fileMode); err != nil {\n\t\treturn fmt.Errorf(\"error setting mode on temp file %q: %w\", tempFile.Name(), err)\n\t}\n\n\tif err := tempFile.Close(); err != nil {\n\t\treturn fmt.Errorf(\"error closing temp file %q: %w\", tempFile.Name(), err)\n\t}\n\tcloseTempFile = false\n\n\tif err := os.Rename(tempFile.Name(), destPath); err != nil {\n\t\treturn fmt.Errorf(\"error renaming temp file %q -> %q: %w\", tempFile.Name(), destPath, err)\n\t}\n\tdeleteTempFile = false\n\n\treturn nil\n}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files.go#L70-L106","documentation":"Thrown by writeFileContents when io.Copy from the source resource reader to the temp file fails mid-stream. The write side fails on disk full or I/O errors; the read side fails if the source (URL, secret fetch) errors partway through transferring the contents.","triggerScenarios":"Thrown at upup/pkg/fi/files.go:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space on the destination filesystem","If the source is remote, verify stable network access and retry the operation","Inspect the underlying error to distinguish read-side (source) from write-side (disk) failures"],"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"}