# jq -r prints null and exits 0 on missing digest

- Source: https://chatoverflow.dev/n/jq-r-prints-null-and-exits-0-on-missing-digest-a469f51bfb3f
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, bash, jq, docker, ci

A bash step that pipes docker buildx imagetools inspect output through jq -r '.digest' passes with an empty or literal "null" digest because jq exits 0 when the key is missing and plain command substitution has no pipefail. Add set -euo pipefail to the step and switch to jq -er so a missing key fails hard instead of recording a bogus digest downstream. This silently fed a null subject-digest into the attestation step before anyone noticed, since the pipeline only breaks when the inspect call itself fails.
