Description
regshape referrer list currently requires a digest reference (registry/repo@sha256:...) and rejects tag references with exit code 2. This is because the OCI Referrers API endpoint (GET /v2/<name>/referrers/<digest>) requires a digest.
However, users most commonly work with tags rather than digests. The command should accept tag references and automatically resolve them to a digest via a HEAD request before querying the referrers API.
Proposed Behavior
When --image-ref contains a tag reference (e.g. registry/repo:v1.0), the command should:
- Issue
HEAD /v2/<name>/manifests/<tag> to resolve the tag to a digest (via the Docker-Content-Digest response header)
- Use the resolved digest to call
GET /v2/<name>/referrers/<digest>
- Proceed as normal with the referrer results
When --image-ref already contains a digest, behavior is unchanged.
Acceptance Criteria
Files to Create/Modify
CLI layer
src/regshape/cli/referrer.py — Remove the digest-only guard; add tag-to-digest resolution using head_manifest before calling list_referrers/list_referrers_all
Library layer
No changes needed — libs/referrers/operations.py already accepts a digest string, and libs/manifests/operations.py already provides head_manifest(client, repo, reference, accept) which returns (digest, media_type, size).
Tests
src/regshape/tests/test_referrer_cli.py — Add tests for tag resolution, update test_tag_reference_rejected_with_exit_code_2 to expect success instead of rejection
Specs
specs/cli/referrer.md — Update accepted formats table and description
Implementation Notes
The tag-to-digest resolution requires a single additional HEAD request. The head_manifest function from libs/manifests already handles this:
from regshape.libs.manifests import head_manifest
from regshape.libs.models.mediatype import ALL_MANIFEST_MEDIA_TYPES
accept = ",".join(sorted(ALL_MANIFEST_MEDIA_TYPES))
digest, _, _ = head_manifest(client, repo, tag, accept)
# Now use digest for the referrers API call
The guard block that currently rejects tags:
if not reference.startswith("sha256:") and not reference.startswith("sha512:"):
emit_error(...)
should be replaced with a resolution step that calls head_manifest to obtain the digest.
References
specs/cli/referrer.md — Current CLI spec
specs/operations/referrers.md — Referrers operations spec
- OCI Distribution Spec: Referrers API requires a digest in the URL path
Description
regshape referrer listcurrently requires a digest reference (registry/repo@sha256:...) and rejects tag references with exit code 2. This is because the OCI Referrers API endpoint (GET /v2/<name>/referrers/<digest>) requires a digest.However, users most commonly work with tags rather than digests. The command should accept tag references and automatically resolve them to a digest via a HEAD request before querying the referrers API.
Proposed Behavior
When
--image-refcontains a tag reference (e.g.registry/repo:v1.0), the command should:HEAD /v2/<name>/manifests/<tag>to resolve the tag to a digest (via theDocker-Content-Digestresponse header)GET /v2/<name>/referrers/<digest>When
--image-refalready contains a digest, behavior is unchanged.Acceptance Criteria
regshape referrer list -i registry/repo:tagresolves the tag and lists referrersregshape referrer list -i registry/repo@sha256:...continues to work as before (no regression)--json,--all,--artifact-type, and--outputflags work with tag references--image-refdescription updated to reflect tag supportspecs/cli/referrer.md) updated to document tag supportFiles to Create/Modify
CLI layer
src/regshape/cli/referrer.py— Remove the digest-only guard; add tag-to-digest resolution usinghead_manifestbefore callinglist_referrers/list_referrers_allLibrary layer
No changes needed —
libs/referrers/operations.pyalready accepts a digest string, andlibs/manifests/operations.pyalready provideshead_manifest(client, repo, reference, accept)which returns(digest, media_type, size).Tests
src/regshape/tests/test_referrer_cli.py— Add tests for tag resolution, updatetest_tag_reference_rejected_with_exit_code_2to expect success instead of rejectionSpecs
specs/cli/referrer.md— Update accepted formats table and descriptionImplementation Notes
The tag-to-digest resolution requires a single additional HEAD request. The
head_manifestfunction fromlibs/manifestsalready handles this:The guard block that currently rejects tags:
should be replaced with a resolution step that calls
head_manifestto obtain the digest.References
specs/cli/referrer.md— Current CLI specspecs/operations/referrers.md— Referrers operations spec