Skip to content

oras discover --format json should show an empty referrers list if no referrer found #1715

@Wwwsylvia

Description

@Wwwsylvia

What happened in your environment?

When using oras discover --format json with ORAS CLI v1.3.0-beta.3, the referrers field is omitted if there are no referrers to the specified manifest. This omission may lead to confusion, as users might not understand that the absence of the referrers field indicates no referrers were discovered.

Current behavior:

 oras discover mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294 --format json
{
  "reference": "mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294",
  "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
  "digest": "sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294",
  "size": 1368
}

In ORAS v1.3.0-beta.2, the output included an empty manifests field (previously named referrers):

 oras discover mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294 --format json
{
  "manifests": []
}

What did you expect to happen?

For such cases, we should update the output to show the referrers field as an empty list:

 oras discover mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294 --format json
{
  "reference": "mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294",
  "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
  "digest": "sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294",
  "size": 1368,
  "referrers": []
}

How can we reproduce it?

Run

oras discover mcr.microsoft.com/dotnet/runtime@sha256:e37c1a16947a303628eb652de1b5b6c0326413877371c99916abb0a1fdb23294 --format json

What is the version of your ORAS CLI?

Version: 1.3.0-beta.3
Go version: go1.24.2
OS/Arch: linux/amd64
Git commit: fce0546
Git tree state: clean

What is your OS environment?

Ubuntu 24.04

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.

Metadata

Metadata

Labels

bugSomething isn't workinguxUser experience related

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions