Skip to content

fix: report no referenceAsTags for an untagged push - #2328

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
MaxFreedomPollard:fix/push-untagged-reference-as-tags
Nov 10, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
MaxFreedomPollard:fix/push-untagged-reference-as-tags

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

oras push <registry>/<repo> <file> --format json reports "referenceAsTags": ["/:"] although nothing was tagged, and --format go-template='{{len .referenceAsTags}}' prints 1. The same happens for an untagged OCI layout push.

OnCopied in the JSON and go-template push handlers records the target reference as a tag when the raw reference is not empty and the reference is not a digest. The raw reference of a push is the destination argument and is never empty, while the reference is empty when no tag is given. The empty reference is recorded as a tag and rendered as ":".

Check the reference itself instead. The existing untagged tests did not catch this because they build a target with an empty raw reference, which the CLI never produces.

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

`oras push <registry>/<repo> <file> --format json` reports
"referenceAsTags": ["<registry>/<repo>:"] although nothing was tagged,
and `--format go-template='{{len .referenceAsTags}}'` prints 1. The
same happens for an untagged OCI layout push.

OnCopied in the JSON and go-template push handlers records the target
reference as a tag when the raw reference is not empty and the
reference is not a digest. The raw reference of a push is the
destination argument and is never empty, while the reference is empty
when no tag is given. The empty reference is recorded as a tag and
rendered as "<repo>:".

Check the reference itself instead. The existing untagged tests did not
catch this because they build a target with an empty raw reference,
which the CLI never produces.

Signed-off-by: Max Freedom Pollard <[email protected]>
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.51%. Comparing base (0f52f9a) to head (aaa2bf2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2328   +/-   ##
=======================================
  Coverage   73.51%   73.51%           
=======================================
  Files         157      157           
  Lines        6582     6582           
=======================================
  Hits         4839     4839           
  Misses       1454     1454           
  Partials      289      289           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TanvirTian TanvirTian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, i checked your PR, everything looks good to me. Optionally, you could add a couple more E2E tests for untagged pushes with JSON output and OCI layouts, but it's not necessary. Looks good overall 🐈

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit 917cfd9 into oras-project:main Nov 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants