argoproj/argo-workflows · error

failed to tarball the output %s to %s: %w

Error message

failed to tarball the output %s to %s: %w

What it means

saveArtifact opened the destination file but archive.TarGzToWriter failed while tarballing the source path (srcPath) into it. This covers read errors on the source (missing file, permission denied, symlink issues) and gzip/tar write errors (disk full). The output artifact is not produced.

Source

Thrown at cmd/argoexec/commands/emissary.go:717

		logger.WithField("srcPath", srcPath).WithError(err).Warn(ctx, "cannot save artifact")
		return nil
	}
	dstPath := filepath.Join(varRunArgo, "/outputs/artifacts/", strings.TrimSuffix(srcPath, "/")+".tgz")
	logger.WithFields(logging.Fields{
		"src": srcPath,
		"dst": dstPath,
	}).Info(ctx, "saving artifact")
	z := filepath.Dir(dstPath)
	if err := os.MkdirAll(z, 0o755); err != nil { // chmod rwxr-xr-x
		return fmt.Errorf("failed to create directory %s: %w", z, err)
	}
	dst, err := os.Create(dstPath)
	if err != nil {
		return fmt.Errorf("failed to create destination %s: %w", dstPath, err)
	}
	defer func() { _ = dst.Close() }()
	if err = archive.TarGzToWriter(ctx, srcPath, gzip.DefaultCompression, dst); err != nil {
		return fmt.Errorf("failed to tarball the output %s to %s: %w", srcPath, dstPath, err)
	}
	if err = dst.Close(); err != nil {
		return fmt.Errorf("failed to close %s: %w", dstPath, err)
	}
	return nil
}

func saveParameter(ctx context.Context, template *wfv1.Template, srcPath string) error {
	logger := logging.RequireLoggerFromContext(ctx)

	if common.FindOverlappingVolume(template, srcPath) != nil {
		logger.WithField("src", srcPath).Info(ctx, "no need to save parameter - on overlapping volume")
		return nil
	}
	src, err := os.Open(filepath.Clean(srcPath))
	if os.IsNotExist(err) { // might be optional, so we ignore
		logger.WithField("src", srcPath).WithError(err).Warn(ctx, "cannot save parameter, does not exist")
		return nil

View on GitHub (pinned to 35bff19146)

Solutions

  1. Read the wrapped error: 'no such file' means fix the template artifact path or mark the artifact optional:true.
  2. Ensure the step actually writes the file at the declared artifact path before the step exits.
  3. Match file ownership: run the container so the file is readable by the argoexec user, or chmod in the step.
  4. Free disk space if the error is a write/ENOSPC failure during compression.

Example fix

// before: artifact path never written by the script
script:
  source: echo hi          # no file at /tmp/out.txt
outputs:
  artifacts:
  - name: result
    path: /tmp/out.txt
// after: either write the file or mark optional
outputs:
  artifacts:
  - name: result
    path: /tmp/out.txt
    optional: true
Defensive patterns

Strategy: validation

Validate before calling

// inside the step, before exit — verify declared outputs exist
for _, art := range template.Outputs.Artifacts {
    if _, err := os.Stat(art.Path); err != nil {
        if !art.Optional {
            return fmt.Errorf("artifact %s missing at %s", art.Name, art.Path)
        }
    }
}

Try / catch

err := runStep(ctx)
if err != nil && strings.Contains(err.Error(), "failed to tarball the output") {
    if errors.Is(errors.Unwrap(err), os.ErrNotExist) {
        // mark artifact optional or fix the path, then retry
        return fixArtifactOrMarkOptional(ctx)
    }
    return err
}

Prevention

When it happens

Trigger: archive.TarGzToWriter(ctx, srcPath, gzip.DefaultCompression, dst) returns error: srcPath does not exist or is unreadable by the executor UID, srcPath is a dangling symlink, the source changed/shrank mid-read, or writes to dst fail with ENOSPC.

Common situations: Output artifact path doesn't exist in the container (task produced nothing but artifact not marked optional); wrong artifact path spelling; permission on the file written by a different user in the same pod; disk fills during a large artifact upload.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/77d7c46edf1b0af0. Report an issue: GitHub.