{"record":{"id":"b38233ee9207cce9","repo":"argoproj/argo-workflows","slug":"failed-to-close-temp-file-w","errorCode":null,"errorMessage":"failed to close temp file: %w","messagePattern":"failed to close temp file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/common/streaming.go","lineNumber":47,"sourceCode":"\tnoop := func() {}\n\n\ttmpFile, err := os.CreateTemp(\"\", pattern)\n\tif err != nil {\n\t\treturn \"\", noop, fmt.Errorf(\"failed to create temp file: %w\", err)\n\t}\n\tname := tmpFile.Name()\n\tcleanup = func() {\n\t\t_ = os.Remove(name)\n\t}\n\n\tif _, err := io.Copy(tmpFile, reader); err != nil {\n\t\t_ = tmpFile.Close()\n\t\tcleanup()\n\t\treturn \"\", noop, fmt.Errorf(\"failed to buffer stream to temp file: %w\", err)\n\t}\n\tif err := tmpFile.Close(); err != nil {\n\t\tcleanup()\n\t\treturn \"\", noop, fmt.Errorf(\"failed to close temp file: %w\", err)\n\t}\n\n\treturn name, cleanup, nil\n}\n","sourceCodeStart":29,"sourceCodeEnd":52,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/common/streaming.go#L29-L52","documentation":"BufferReaderToTempFile spools an io.Reader into a temp file so artifacts can be saved via SaveStreamViaTempFile. This error wraps a failure from tmpFile.Close() after the stream was successfully written; close can flush buffered data and fail (e.g. ENOSPC), so it is checked explicitly. The temp file is removed and the write is abandoned when this happens.","triggerScenarios":"Calling SaveStreamViaTempFile (or BufferReaderToTempFile directly) with a stream whose bytes were written fine to the temp file, but where the final Close() on the temp file fails — typically disk full on the node, an I/O error, or the file having been closed/invalid already.","commonSituations":"Executor pod running on a node whose emptyDir/tmp volume is full while capturing large script outputs or logs; disk-pressure-evicted nodes; read-only tmp mounts.","solutions":["Free disk space on the node / increase the ephemeral storage size for the workflow pod","Check node disk health (dmesg for I/O errors) and move the workflow to a healthy node","Retry the workflow; if it recurs, check kubelet ephemeral-storage limits"],"exampleFix":"// before\nif err := tmpFile.Close(); err != nil {\n\tcleanup()\n\treturn \"\", noop, fmt.Errorf(\"failed to close temp file: %w\", err)\n}\n// after\n// no code fix in caller; fix is infra: ensure the executor's temp volume has free space, e.g.\n// spec.volumes: [{name: tmp, emptyDir: {sizeLimit: 1Gi}}] and adequate node disk","handlingStrategy":"validation","validationCode":"// before submitting workflows that emit large artifacts, check executor disk space:\n// kubectl describe node <node> | grep -A3 'Ephemeral Storage'\n// or inside a probe step:\nimport \"syscall\"\nvar st syscall.Statfs_t\n_ = syscall.Statfs(\"/tmp\", &st)\nfreeBytes := st.Bavail * uint64(st.Bsize)\nif freeBytes < 512<<20 { /* skip / fail fast */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set emptyDir sizeLimit generously for artifact-heavy workflows","Monitor node disk pressure conditions (KubeletDiskPressure)","Keep script stdout/outputs small; offload large data to object storage directly"],"tags":["io","filesystem","artifacts","disk-space"],"backgroundTag":"disk-full-write-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}