Skip to content

Formating output of oras manifest fetch with go-templates doesn't work on all fields #1947

@ggjulio

Description

@ggjulio

What happened in your environment?

I'm trying to get the value of some fields in a manifest.

manifest example
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.cncf.helm.config.v1+json",
    "digest": "sha256:eaea14941b04bcdb0595c359a31f8dab61f137299c9fa5410c74d2408cda1789",
    "size": 220
  },
  "layers": [
    {
      "mediaType": "application/vnd.cncf.helm.chart.content.v1.tar+gzip",
      "digest": "sha256:0090c532386f29b8436c34eb56055e922f2d0fd6adda1b83fc924717b1ae994f",
      "size": 45915,
      "annotations": {
        "org.opencontainers.image.title": "target/dh-7.5.0-0-SNAPSHOT.tgz"
      }
    }
  ],
  "annotations": {
    "org.opencontainers.image.authors": "redacted,
    "org.opencontainers.image.created": "2025-12-17T09:20:56Z",
    "org.opencontainers.image.description": "redacted",
    "org.opencontainers.image.revision": "e12fb7954a7e8cbfa61b4fd740fd70519f137cbb",
    "org.opencontainers.image.title": "redacted",
    "org.opencontainers.image.vendor": "redacted",
    "org.opencontainers.image.version": "0.1.0"
  }
}

This one works:

  • oras manifest fetch --format go-template --template='{{ index .mediaType }}' $OCI_REF

Theses one don't

  • oras manifest fetch --format go-template --template='{{ .config.mediaType }}' $OCI_REF
  • oras manifest fetch --format go-template --template='{{ index .config.mediaType }}' $OCI_REF
  • oras manifest fetch --format go-template --template='{{ index .annotations "org.opencontainers.image.revision"}}' $OCI_REF

Log output example:

$> oras manifest fetch --format go-template --template='{{ index .annotations }}' $OCI_REF
Error: template: format output:1:3: executing "format output" at <index .annotations>: error calling index: index of untyped ni

Maybe related to this: #1276

What did you expect to happen?

No response

How can we reproduce it?

.

What is the version of your ORAS CLI?

Version: 1.3.0
Go version: go1.25.0
OS/Arch: linux/amd64
Git commit: 40530fe
Git tree state: clean

What is your OS environment?

debian trixie

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues or PRs to be acknowledged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions