Cannot push tag "because it already exists" (3.8.2)

221 views
Skip to first unread message

John de Largentaye

unread,
Nov 6, 2024, 8:10:34 PM11/6/24
to Repo and Gerrit Discussion
Hi,

I'm struggling to be able to push annotated tags over Gerrit v3.8.2, which fails like this:

$ git push origin tag V2.2.19354.D09-g4a126e4
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 182 bytes | 9.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, done
To ssh://server.corp.com:29418/PROJECT
 ! [remote rejected]         V2.2.19354.D09-g4a126e4 -> V2.2.19354.D09-g4a126e4 (Cannot create ref 'refs/tags/V2.2.19354.D09-g4a126e4' because it already exists.)
error: failed to push some refs to 'ssh://server.corp.com:29418/PROJECT'

The tag does not exist on the server, so the error is confusing.

What's astounding is this appears related to the tag name. Indeed if I try to create a differently named tag, that goes fine:

$ git tag -m "test tag" JLARGENTAYE-TEST
$ git push origin tag JLARGENTAYE-TEST
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 179 bytes | 8.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, done
To ssh://server.corp.com:29418/PROJECT
 * [new tag]                 JLARGENTAYE-TEST -> JLARGENTAYE-TEST

I notice that our main (problematic) tag format is based on git-describe output, and that git can parse that as a revision. That is, even if the tag does not exist, `git show V2.2.19354.D09-g4a126e4` will show a commit! See the 'describeOutput` format at https://git-scm.com/docs/gitrevisions#_specifying_revisions

Could this be a bug in how Gerrit verifies pre-existence of a tag/reference?

John de Largentaye

unread,
Nov 6, 2024, 8:17:50 PM11/6/24
to Repo and Gerrit Discussion
On Wednesday, November 6, 2024 at 5:10:34 PM UTC-8 John de Largentaye wrote:

The tag does not exist on the server, so the error is confusing.

To expand on this part, I verified the problematic tag does not actually already exist on the server by doing the following:
- on the server, run `git tag -l | grep V2.2.19354.D09-g4a126e4`, which returns nothing
- on the server, attempt to delete the tag:
    % git tag -d V2.2.19354.D09-g4a126e4
    error: tag 'V2.2.19354.D09-g4a126e4' not found.

Sven Selberg

unread,
Nov 7, 2024, 2:06:11 AM11/7/24
to Repo and Gerrit Discussion
On Thursday, November 7, 2024 at 2:17:50 AM UTC+1 John de Largentaye wrote:
On Wednesday, November 6, 2024 at 5:10:34 PM UTC-8 John de Largentaye wrote:

The tag does not exist on the server, so the error is confusing.

To expand on this part, I verified the problematic tag does not actually already exist on the server by doing the following:
- on the server, run `git tag -l | grep V2.2.19354.D09-g4a126e4`, which returns nothing

For trouble-shooting, could you try

$ git show-ref | grep g4a126e4

John de Largentaye

unread,
Nov 7, 2024, 1:37:26 PM11/7/24
to Sven Selberg, Repo and Gerrit Discussion
On Wed, Nov 6, 2024 at 11:06 PM Sven Selberg <sven.s...@axis.com> wrote:

For trouble-shooting, could you try

$ git show-ref | grep g4a126e4

I tried, and it returns nothing, as expected. 

Sven Selberg

unread,
Nov 8, 2024, 1:44:05 AM11/8/24
to Repo and Gerrit Discussion
I would try to push the tag with tracing to see what's going on.
https://gerrit-review.googlesource.com/Documentation/user-request-tracing.html
 

Matthias Sohn

unread,
Nov 8, 2024, 3:31:15 AM11/8/24
to Sven Selberg, Repo and Gerrit Discussion
Is the tag shown when you run git ls-remote ? 

John de Largentaye

unread,
Mar 5, 2025, 7:00:15 PM3/5/25
to Repo and Gerrit Discussion
Hi repo-discuss,

resurfacing this topic, which is still happening on an updated Gerrit server v3.11.1.

To recap: Gerrit is rejecting direct pushes of annotated tags that have a certain name (name derived from 'git describe', fwiw) with the surprising message:
    Cannot create ref 'refs/tags/V1.99.0026-g84775c3' because it already exists
To be clear, the tag does not exist on the server, as verified by:
1. running on the server "git show-ref | grep 84775c3" (shows only the refs/heads/Branchname, not refs/tags/)
2. running locally "git ls-remote origin | grep 84775c3" (as above, shows the branch, not the tag)

Update:
I tried tracing as Sven suggested, attaching to this message the relevant section of error_log as "gerrit-tag-trace.txt", but as far as I can tell, there is no additional information other than the error message above.
I did the trace with:
    git push -o trace=push-tag-1 origin V1.99.0026-g84775c3

Other perhaps relevant points:
- I pushed as myself & am administrator, but other normal users reported the same problem
- The project config allows creating annotated tags, here is the relevant section:
    [access "refs/tags/*"]
create = group Administrators
create = group Project Owners
create = group Registered Users
createSignedTag = group Administrators
createSignedTag = group Project Owners
createSignedTag = group Registered Users
createTag = group Administrators
createTag = group Project Owners
createTag = group Registered Users
push = +force group Administrators
push = +force group Project Owners
push = group Registered Users
- I am able to push tags with more "boring" names. For example this works:
    git tag -a -m "Testing gerrit tag push" gerrit-test-tag-1
    git push origin gerrit-test-tag-1
gerrit-tag-trace.txt

narendra kumar

unread,
Mar 6, 2025, 3:30:26 AM3/6/25
to Repo and Gerrit Discussion
That is because the tag already exists, in a way. Tag names with `-g` are treated differently. Your tag V2.2.19354.D09-g4a126e4, is refers to commit with hash 4a126e4 which is reachable from tag V2.2.19354.D09?
A change in Gerrit that validates ref doesn't exist before creation is causing this issue, I think that commit is: a9f84e9e3494f45652221c0e96a0809ec0e969b1. A simple fix is to add a suffix like '-v' to the tag name so that it becomes: V2.2.19354.D09-g4a126e4-v. Or a source code change be done to restrict the validation to look narrowly if push is for a tag.

John de Largentaye

unread,
Mar 6, 2025, 2:12:45 PM3/6/25
to narendra kumar, Repo and Gerrit Discussion
Thanks, Narendra!

Unfortunately, we cannot change our tag format, as we have about a decade of infrastructure built around that, before we adopted Gerrit.



--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to a topic in the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/repo-discuss/uHaGpxufRjk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/c9bc5fab-5126-4ba6-a48c-3c0a5a0fb77cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages