Skip to content

oras attach ignores --annotation $config:key=val when --config is not provided #2022

Closed

Description

@TerryHowe

Description

oras attach silently drops config annotations set via --annotation $config:key=val when the --config flag is not also provided.

This is because runAttach never sets packOpts.ConfigAnnotations, so oras-go generates the default config without applying the requested annotations.

In contrast, oras push unconditionally sets:

packOpts := oras.PackManifestOptions{
    ConfigAnnotations: opts.Annotations[option.AnnotationConfig],
    ...
}

so config annotations are applied to the auto-generated config even when no --config flag is given.

Steps to reproduce

oras attach --artifact-type doc/example \
  --annotation '$config:org.example.key=value' \
  localhost:5000/hello:v1 hi.txt

Fetch the resulting manifest — the config descriptor will have no annotations, even though --annotation $config:... was specified.

Expected behavior

Config annotations should be applied to the default config descriptor, consistent with oras push behavior.

Fix

In runAttach (cmd/oras/root/attach.go), set ConfigAnnotations on packOpts unconditionally:

packOpts := oras.PackManifestOptions{
    Subject:             &subject,
    ConfigAnnotations:   opts.Annotations[option.AnnotationConfig],
    ManifestAnnotations: opts.Annotations[option.AnnotationManifest],
    Layers:              descs,
}

Activity

  1. added a commit that references this issue on May 26, 2026
    9a37a4e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions