argoproj/argo-workflows · error
failed to buffer stream to temp file: %w
Error message
failed to buffer stream to temp file: %w
What it means
After creating the temp file, BufferReaderToTempFile copies the artifact stream into it with io.Copy. If the source reader errors mid-copy (or writing to the temp file fails, e.g. disk full), the temp file is closed/removed and this error is returned wrapping the cause.
Source
Thrown at workflow/artifacts/common/streaming.go:43
// function that removes it; cleanup is safe to call more than once. On error, any partially
// written temp file is removed before returning, so callers only need to defer cleanup
// after a nil error.
func BufferReaderToTempFile(reader io.Reader, pattern string) (path string, cleanup func(), err error) {
noop := func() {}
tmpFile, err := os.CreateTemp("", pattern)
if err != nil {
return "", noop, fmt.Errorf("failed to create temp file: %w", err)
}
name := tmpFile.Name()
cleanup = func() {
_ = os.Remove(name)
}
if _, err := io.Copy(tmpFile, reader); err != nil {
_ = tmpFile.Close()
cleanup()
return "", noop, fmt.Errorf("failed to buffer stream to temp file: %w", err)
}
if err := tmpFile.Close(); err != nil {
cleanup()
return "", noop, fmt.Errorf("failed to close temp file: %w", err)
}
return name, cleanup, nil
}
View on GitHub (pinned to 35bff19146)
Solutions
- Inspect the wrapped error: read errors indicate upstream/network problems; write errors (ENOSPC) indicate disk space.
- Retry the operation — the temp file is cleaned up automatically so no stale artifacts remain.
- Free/expand disk on the temp filesystem before re-running large artifacts.
- Add timeouts/retries upstream or fetch from a more reliable replica of the artifact.
- If streaming from HTTP artifacts, ensure the artifact server / source URL supports stable long-lived transfers.
Defensive patterns
Strategy: retry
Validate before calling
// ensure space for the expected artifact size before buffering
if st, ok := reader.(interface{ Len() int }); ok {
if free, _ := diskFree(os.TempDir()); free < uint64(st.Len()) {
return errors.New("insufficient temp disk space for artifact stream")
}
} Try / catch
err := artifactscommon.SaveStreamViaTempFile(reader, "upload-*", save)
if err != nil && strings.Contains(err.Error(), "failed to buffer stream") {
if errors.Is(err, syscall.ENOSPC) {
return fmt.Errorf("temp volume full during transfer: %w", err)
}
return fmt.Errorf("transient stream error, retry: %w", err) // temp file already cleaned up
} Prevention
- Size the temp volume for the largest expected artifact.
- Use retryable readers (fresh HTTP requests per attempt) so retries can restart the stream.
- Monitor node disk pressure conditions in Kubernetes.
- Set read/write timeouts on upstream artifact sources to fail fast rather than hang.
When it happens
Trigger: io.Copy fails because the upstream reader errors: HTTP/S3/Azure stream broken mid-download, TLS timeout, or the temp filesystem fills up while writing (ENOSPC).
Common situations: Streaming large artifacts from flaky networks; storage backend returning 200-then-truncated body; disk quota on the node reached during save; interrupted upstream artifact service.
Related errors
- failed to create temp file: %w
- failed to copy %s to %s: %w
- failed to close temp file: %w
- plugin %s stream write failed: %w
- plugin %s save stream failed to read artifact content: %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/62bc212273c6a2a8.
Report an issue: GitHub.