#7130·buildah

manifest push: push error discarded when `--digestfile` is used, exits 0

Author: skoefCreated Sep 23, 2026Updated Sep 29, 2026

Issue Description

buildah manifest push --digestfile writes an empty digest file and exits 0 when the push fails.

Two separate problems in manifestPush() in cmd/buildah/manifest.go combine to produce this:

go
_, digest, err := list.Push(getContext(), dest, options)

if err == nil && opts.rm {
	_, err = store.DeleteImage(manifestList.ID(), true)
}

if opts.digestfile != "" {
	if err = os.WriteFile(opts.digestfile, []byte(digest.String()), 0o644); err != nil {
		return util.GetFailureCause(err, fmt.Errorf("failed to write digest to file %q: %w", opts.digestfile, err))
	}
}

return err
  1. The opts.digestfile block is not guarded by err == nil, so it runs even when list.Push failed. On the failure path digest is the zero value, and since digest.Digest is a string type whose String() is a plain cast, digest.String() returns "" an empty file is written.

  2. if err = os.WriteFile(...) assigns to the existing err rather than declaring a new one. When WriteFile succeeds it overwrites the push error with nil, so the closing return err returns nil and the command exits successfully.

The second point is the more serious one: the push error is swallowed entirely, so the failure is invisible to any caller checking the exit code.

Note that buildah push does not have this bug. In cmd/buildah/push.go the error path returns early, so the digestfile is only written after a successful push. Only manifest push is affected.

Steps to reproduce the issue

  1. Create a manifest list with at least one image:
bash
$ buildah manifest create example
$ buildah build --manifest example --platform linux/amd64 -t example .
  1. Push it to a destination that will fail, e.g. a registry you are not authenticated against, or one that does not exist:
bash
$ buildah manifest push --all --digestfile /tmp/digest example docker://registry.invalid/nonexistent/repo
$ echo "exit status: $?"
$ ls -l /tmp/digest
$ wc -c /tmp/digest

Describe the results you received

The push fails, but the exit status is 0 and /tmp/digest exists with a size of 0 bytes. No error is reported from the push itself.

bash
exit status: 0
-rw-r--r--. 1 user user 0 ... /tmp/digest
0 /tmp/digest

Describe the results you expected

A non-zero exit status and the push error propagated to the caller. The digest file should not be created or written at all when the push fails, a caller should never observe an empty digest file.

buildah version output

bash
(verified by code inspection against tag v1.45.1 and main at 596ece93bbb07d15c53c5b044a08326c4a72acce; the affected code is identical in both)

buildah info output

I'm running this from a CI pipeline, that only outputs buildah version

bash
Version:         1.43.1
Go Version:      go1.26.1-X:nodwarf5
Image Spec:      1.1.1
Runtime Spec:    1.2.1
CNI Spec:        1.1.0
libcni Version:  
image Version:   5.39.2
Git Commit:      
Built:           Wed Apr  8 19:37:51 2026
OS/Arch:         linux/arm64
BuildPlatform:   linux/arm64/v8

Provide your storage.conf

bash
[storage]
      driver = "vfs"
      graphRoot = "${CI_PROJECT_DIR}/.buildah-storage"
      runRoot = "/tmp/buildah-run"

Upstream Latest Release

Yes

Additional environment details

Encountered in CI (GitLab CI) using the quay.io/buildah/stable image. The practical impact is that a pipeline step doing buildah manifest push --digestfile ... succeeds despite pushing nothing, and a later step that reads the digest file gets an empty value. In our case the next step signs the pushed image with cosign, so a failed push silently turned into a green pipeline with an unsigned (and nonexistent) image. We now have to defensively check that the digest file is both present and non-empty.

Additional information

A minimal fix is to guard the write and avoid clobbering err:

go
_, digest, err := list.Push(getContext(), dest, options)
if err != nil {
	return err
}

if opts.rm {
	if _, err := store.DeleteImage(manifestList.ID(), true); err != nil {
		return err
	}
}

if opts.digestfile != "" {
	if err := os.WriteFile(opts.digestfile, []byte(digest.String()), 0o644); err != nil {
		return util.GetFailureCause(err, fmt.Errorf("failed to write digest to file %q: %w", opts.digestfile, err))
	}
}

return nil

Source: podman-container-tools/buildah