Cannot delete merged change via rest api with auth

63 views
Skip to first unread message

Denis Khabensky

unread,
Jun 11, 2025, 11:56:29 AM6/11/25
to Repo and Gerrit Discussion

Hello!

I have a list of incorrectly created changes (for already-merged commits) which I want to delete completely and recreate with proper owners. 

Using rest api for this:
curl -v --user dhabensky:$GERRIT_PASS -X DELETE "https://gerrit.yandex-team.ru/a/changes/72052"

But the answer is:
405 Method Not Allowed
delete not permitted

I tried this with multiple change-id notations, for multiple changes, all with same result.
I am the owner of this change and also an administrator, so gerrit should allow me to do this.
I suspect that authorization (using /a/changes instead of /changes) is a deal-breaker here, but we dont allow any anonymous access to our gerrit instance.

How can I delete such change?

Gerrit 3.11.1

Matthias Sohn

unread,
Jun 11, 2025, 12:30:44 PM6/11/25
to Denis Khabensky, Repo and Gerrit Discussion
AFAIK Gerrit doesn't allow deleting merged changes, but only abandoned changes.
Rewriting merged commits is a complex surgery manipulating the history.
In addition to rewriting the commit(s) associated with the change you would need to rewrite the related notedb content.

Instead of rewriting these commits I would consider to revert them and then create the new changes on top of that revert.
 
--
--
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 the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/ec91fe27-cdfc-4ebd-8276-ab9a8baf7cfcn%40googlegroups.com.

Denis Khabensky

unread,
Jun 11, 2025, 1:02:14 PM6/11/25
to Repo and Gerrit Discussion
Im not speaking about deleting actual commits in repositories - they existed long before and should continue forever.
Im interested only in deleting change information from notedb, so we can recreate changes for the same commits but with proper data.
So I dont need a complete surgery.
But I also cannot revert commits - time has passed since they were created, this is what looks like a complex surgery now.

среда, 11 июня 2025 г. в 19:30:44 UTC+3, Matthias Sohn:

Luca Milanesio

unread,
Jun 11, 2025, 1:38:07 PM6/11/25
to Repo and Gerrit Discussion, Luca Milanesio

On 11 Jun 2025, at 18:02, Denis Khabensky <dhab...@gmail.com> wrote:

Im not speaking about deleting actual commits in repositories - they existed long before and should continue forever.
Im interested only in deleting change information from notedb, so we can recreate changes for the same commits but with proper data.

What do you mean by “recreate changes for the same commit but with proper data”?
Can you share how your code review workflow looks like?
Do you have reference?

So I dont need a complete surgery.
But I also cannot revert commits - time has passed since they were created, this is what looks like a complex surgery now.

Why don’t you just remove the refs/changes/* pointing to those commits and run an offline reindex then?

HTH

Luca.

Denis Khabensky

unread,
Jun 11, 2025, 2:17:16 PM6/11/25
to Repo and Gerrit Discussion

> What do you mean by “recreate changes for the same commit but with proper data”?
   Can you share how your code review workflow looks like?
   Do you have reference?

Current problem is not related with code review process.
Instead, we migrated sources from external remotes to internal gerrit and now want to create 'gerrit changes' for old commits. They should look like if they were reviewed and submitted via gerrit.
We need this cause some our internal code crawlers only work with gerrit changes, not raw commits.

> Why don’t you just remove the refs/changes/* pointing to those commits and run an offline reindex then?

Yes, this looks like what I need, thanks!

среда, 11 июня 2025 г. в 20:38:07 UTC+3, Luca Milanesio:

Denis Khabensky

unread,
Jun 11, 2025, 2:49:29 PM6/11/25
to Repo and Gerrit Discussion
> Why don’t you just remove the refs/changes/* pointing to those commits and run an offline reindex then?

How can I do so / which permissions do I need?
I tried to delete change 72091, with the following errors (I am in group Administrators):

git push --delete origin refs/changes/91/72091/1
remote: error: branch refs/changes/91/72091/1:
remote: Cannot delete from 'refs/changes/'
remote: User: dhabensky
remote: Contact an administrator to fix the permissions
remote: Processing changes: refs: 1, done    
To ssh://gerrit.yandex-team.ru/dhabensky-test
 ! [remote rejected] refs/changes/91/72091/1 (The ref refs/changes/91/72091/1 doesn't exist)
error: failed to push some refs to 'ssh://gerrit.yandex-team.ru/dhabensky-test'

git push --delete origin refs/changes/91/72091/meta -o notedb=allow
remote: Processing changes: refs: 1, done    
remote: ACL info:
...
To ssh://gerrit.yandex-team.ru/dhabensky-test
 ! [remote rejected] refs/changes/91/72091/meta (NoteDb update requires access database permission)
error: failed to push some refs to 'ssh://gerrit.yandex-team.ru/dhabensky-test'



среда, 11 июня 2025 г. в 21:17:16 UTC+3, Denis Khabensky:

Matthias Sohn

unread,
Jun 11, 2025, 3:41:11 PM6/11/25
to Denis Khabensky, Repo and Gerrit Discussion
On Wed, Jun 11, 2025 at 8:49 PM Denis Khabensky <dhab...@gmail.com> wrote:
> Why don’t you just remove the refs/changes/* pointing to those commits and run an offline reindex then?

How can I do so / which permissions do I need?
I tried to delete change 72091, with the following errors (I am in group Administrators):

git push --delete origin refs/changes/91/72091/1
remote: error: branch refs/changes/91/72091/1:
remote: Cannot delete from 'refs/changes/'
remote: User: dhabensky
remote: Contact an administrator to fix the permissions
remote: Processing changes: refs: 1, done    
To ssh://gerrit.yandex-team.ru/dhabensky-test
 ! [remote rejected] refs/changes/91/72091/1 (The ref refs/changes/91/72091/1 doesn't exist)
error: failed to push some refs to 'ssh://gerrit.yandex-team.ru/dhabensky-test'

git push --delete origin refs/changes/91/72091/meta -o notedb=allow
remote: Processing changes: refs: 1, done    
remote: ACL info:
...
To ssh://gerrit.yandex-team.ru/dhabensky-test
 ! [remote rejected] refs/changes/91/72091/meta (NoteDb update requires access database permission)
error: failed to push some refs to 'ssh://gerrit.yandex-team.ru/dhabensky-test'

Gerrit doesn't allow low level surgery via API. You can only do this behind Gerrit's back running git on the server side repo.
Be careful, first try this on a staging copy and create a backup before you do this in production.

Reply all
Reply to author
Forward
0 new messages