Skip to content

--oci-layout-path accepts custom header flags that --oci-layout rejects #2298

Description

@ogulcanaydogan

What happened in your environment?

--oci-layout rejects custom header flags, but --oci-layout-path (and --from-oci-layout-path / --to-oci-layout-path) accepts them and ignores them:

$ oras manifest fetch --oci-layout layout:v1 -H foo:bar
Error: custom header flags cannot be used on an OCI image layout target

$ oras manifest fetch v1 --oci-layout-path layout -H foo:bar
(no error, the header is not used)

In Target.Parse (cmd/oras/internal/option/target.go) the check is only in the case target.IsOCILayout: branch. The case target.Path != "": branch also sets the target type to oci-layout but has no such check.

I found this by reading the code and checked it with a unit test on Target.Parse (the e2e test for this error only covers --oci-layout), not by running the CLI.

What did you expect to happen?

The same error for both ways of selecting an OCI image layout target.

How can we reproduce it?

Pass a header flag together with --oci-layout-path, for example oras manifest fetch v1 --oci-layout-path layout -H foo:bar, or run the unit test in the linked PR.

What is the version of your ORAS CLI?

main (bc7b32d)

What is your OS environment?

macOS

Are you willing to submit PRs to fix it?

Yes, I opened a PR.

Activity

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