Gerrit3.4.1:Error:no viable alternative at character '&'

236 views
Skip to first unread message

Echo

unread,
Dec 28, 2021, 4:09:02 AM12/28/21
to Repo and Gerrit Discussion
Dear ALL:
My Gerrit is 3.4.1,and when I create a project named test&build/work,it is successfully.
but when I push a patch set to this project,it's open page show this error:
Error 400 (Bad Request):no viable alternative at character '&'
(1)is it the name of gerrit project no surport to "&"?
(2)in order to resolve this error,I have downloaded  rename-project plugin to fix the name.but when I do "ssh -p <port> <IP> rename-project test&build/work test_build/work",it warned the error again:no viable alternative at "&"?

if anyone let me know how can I resolve this error?
thank you  very much for any reply.

Sven Selberg

unread,
Dec 28, 2021, 5:51:06 AM12/28/21
to Repo and Gerrit Discussion
Since the project is new and has no changes you should be able to:
1. Rename git on the server:
    $ sudo su - $GERRIT_USER
    $ cd $GERRIT_SITE/git
    $ mv test\&build test-and-build
2 Flush project cache.

Echo

unread,
Dec 29, 2021, 1:10:49 AM12/29/21
to Repo and Gerrit Discussion
this is the other strange thing:
our first Gerrit version is 2.11,and I surely can rename the name of project by mving  test\&build to test-and-build in gerrit server,and no care for if it has had changes ,even no flush cache.
but now when I upgrade to 3.4.1,it seems that this way is not effective,if anything I have missed??
my steps is :
    $ sudo su - $GERRIT_USER
    $ cd $GERRIT_SITE/git
    $ mv test\&build test-and-build
$ ssh -p 29418 <ip> gerrit flush-caches --cache projects
$  ssh -p 29418 <ip> gerrit flush-caches --cache project_list

the last ,I even restart the gerrit service,but the result is still not what I want.
In fact,when I do this ,this project is disappeared,also with all merged changes in it.

Matthias Sohn

unread,
Dec 29, 2021, 9:05:45 AM12/29/21
to Echo, Repo and Gerrit Discussion
On Wed, Dec 29, 2021 at 7:10 AM Echo <yangqia...@gmail.com> wrote:

please avoid top posting on this list
 
this is the other strange thing:
our first Gerrit version is 2.11,and I surely can rename the name of project by mving  test\&build to test-and-build in gerrit server,and no care for if it has had changes ,even no flush cache.
but now when I upgrade to 3.4.1,it seems that this way is not effective,if anything I have missed??
my steps is :
    $ sudo su - $GERRIT_USER
    $ cd $GERRIT_SITE/git
    $ mv test\&build test-and-build
$ ssh -p 29418 <ip> gerrit flush-caches --cache projects
$  ssh -p 29418 <ip> gerrit flush-caches --cache project_list

the last ,I even restart the gerrit service,but the result is still not what I want.
In fact,when I do this ,this project is disappeared,also with all merged changes in it.

It is not recommended to change project names in this way since it doesn't rebuild the affected indexes
and would break existing project watches. Instead install the rename-project plugin [1] and use its
rename-project command [2] to rename repositories.


-Matthias

在2021年12月28日星期二 UTC+8 18:51:06<Sven Selberg> 写道:
On Tuesday, December 28, 2021 at 10:09:02 AM UTC+1 yangqia...@gmail.com wrote:
Dear ALL:
My Gerrit is 3.4.1,and when I create a project named test&build/work,it is successfully.
but when I push a patch set to this project,it's open page show this error:
Error 400 (Bad Request):no viable alternative at character '&'
(1)is it the name of gerrit project no surport to "&"?
(2)in order to resolve this error,I have downloaded  rename-project plugin to fix the name.but when I do "ssh -p <port> <IP> rename-project test&build/work test_build/work",it warned the error again:no viable alternative at "&"?

if anyone let me know how can I resolve this error?

Since the project is new and has no changes you should be able to:
1. Rename git on the server:
    $ sudo su - $GERRIT_USER
    $ cd $GERRIT_SITE/git
    $ mv test\&build test-and-build
2 Flush project cache.

 
thank you  very much for any reply.

--
--
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 on the web visit https://groups.google.com/d/msgid/repo-discuss/a433b204-1413-461c-bac0-38f269225053n%40googlegroups.com.

Echo

unread,
Dec 29, 2021, 8:16:54 PM12/29/21
to Repo and Gerrit Discussion
rename-project plugin is my init question:
"(2)in order to resolve this error,I have downloaded  rename-project plugin to fix the name.but when I do "ssh -p <port> <IP> rename-project test&build/work test_build/work",it warned the error again:no viable alternative at "&"? "
and I try $ ssh -p <port> <IP> rename-project "test\&build/work" test_build/work   also,it's still show error: no viable alternative at "&"? 

Sven Selberg

unread,
Jan 3, 2022, 3:44:39 AM1/3/22
to Repo and Gerrit Discussion
On Thursday, December 30, 2021 at 2:16:54 AM UTC+1 yangqia...@gmail.com wrote:
rename-project plugin is my init question:
"(2)in order to resolve this error,I have downloaded  rename-project plugin to fix the name.but when I do "ssh -p <port> <IP> rename-project test&build/work test_build/work",it warned the error again:no viable alternative at "&"? "
and I try $ ssh -p <port> <IP> rename-project "test\&build/work" test_build/work   also,it's still show error: no viable alternative at "&"? 

在2021年12月29日星期三 UTC+8 22:05:45<Matthias Sohn> 写道:
On Wed, Dec 29, 2021 at 7:10 AM Echo <yangqia...@gmail.com> wrote:

please avoid top posting on this list
 
this is the other strange thing:
our first Gerrit version is 2.11,and I surely can rename the name of project by mving  test\&build to test-and-build in gerrit server,and no care for if it has had changes ,even no flush cache.
but now when I upgrade to 3.4.1,it seems that this way is not effective,if anything I have missed??

In your initial question you said that you were using 3.4.1. With 3.4.1, if the project is newly created and therefore have no submodule subscriptions etc., it should work to just rename the project on disk and update project caches.
But from what I can tell by what your saying here you situation is much more complex.

Does this project already exist with changes in your 2.11 instance and you get a failure when trying to upgrade to v3.4.1?
If so it seems like Gerrit 2.11 accepts "&" in the project-name but gerrit 3.4.1 does not. Did you try to use the rename-project plugin on your 2.11 instance before upgrading to v3.4.1?

Nguyen Tuan Khang Phan

unread,
Jan 5, 2022, 9:11:00 AM1/5/22
to Repo and Gerrit Discussion
Hi,
Is it possible to share with us the stack trace that the rename-project plugin generates, I would like to see at which step it fails?

Echo

unread,
Jan 5, 2022, 8:03:56 PM1/5/22
to Repo and Gerrit Discussion
(1) my "test&build/work" project is newly create in 3.4.1 and when I "create new project" there is not any warning about illegal character . it is just warning when I create a patch set in this project , and if I "dissmiss" the warning the change page will show normal until I newly open this page the next time it warning again.
warning log is : An error occurred
                           Error 400 (Bad Request): line 1:18 no viable alternative at character '&'
                           Endpoint : /changes/change:* 

(2) my gerrit 3.4.1 and 2.11 is two independent code server.( my 2.11 is so out of style that upgrading to 3.4.1 is difficult.so I retain 2.11 and create a new 3.4.1 to review different code )
I just find that I can rename the name of existing project by modifing the name of project in git server of 2.11,but this way is not efficient with 3.4.1.

(3) gerrit plugin has no support to 2.11, so I can't test if rename-project plugin is useful for 2.11. 

Echo

unread,
Jan 5, 2022, 8:46:25 PM1/5/22
to Repo and Gerrit Discussion
when I execute :
$ ssh -p 29418 <my.dns.com> rename-project test&build/work test_build/work ,the error log is as follow:
Checking preconditions:                          100%
fatal: com.google.gerrit.extensions.restapi.BadRequestException: line 1:17 no viable alternative at character '&'
( test&build/work is just an example,not true name , but the structure of it is the same as the true name )
( and I also try "test&build/work" , "test\&build/work", 'test&build/work' ,the error log is the same.)

and I also get rename.log,error_log and sshd_log from gerrit server , as follow:
rename.log is empty
error_log shows no log for rename-project
sshd_log shows:
[2022-01-06T09:20:32.377+08:00] 8dd9b44c [SSH rename-project test&build/work  test_build/work   (username)] username a/1000000 rename-project.  test&build/work . test_build/work   5ms 2ms - 1 - 2ms 0ms 277640
[2022-01-06T09:20:32.428+08:00] 8dd9b44c [sshd-SshDaemon[3fd7be2d](port=22)-nio2-thread-6] username a/1000000 LOGOUT

Nguyen Tuan Khang Phan

unread,
Jan 6, 2022, 7:14:23 AM1/6/22
to Repo and Gerrit Discussion
From the code perspective, it is failing to get the list of changes for your project. I tried to run the plugin to rename on 2.14 and it worked (using the same name you used). So maybe you will have to stop at 2.14 and rename some projects with special chars.

Echo

unread,
Jan 9, 2022, 8:44:56 PM1/9/22
to Repo and Gerrit Discussion
Thank you for your answers and I have found the effective solution,as follow:

(1) these should be executed in Gerrit server:    ( it can avoid the error of special chars when someone uses rename-project plugin )
$ cd $gerrit_home/review_site/git
$ mv "test&build" test_builds
(2) these should be executed after enableing rename-project plugin:
$ ssh -p 29418 <gerrit.ip> rename-project test_builds/work test_build/work
$ ssh -p 29418 <gerrit.ip> flush-caches --cache projects     (or you can restart the gerrit service)

by doing these ,I renamed my project from "test&build/work" to "test_build/work" and all of its changes is show correct,in fact, everything is OK. :-)
Again, thanks very much for everyone's replies.


Nguyen Tuan Khang Phan

unread,
Jan 10, 2022, 8:22:29 AM1/10/22
to Repo and Gerrit Discussion
Thank you for your input. However, I am interested if you tried to use the --replication option for the rename-project. This option only does file rename. [1]

[1] https://gerrit.googlesource.com/plugins/rename-project/+/f49236d1b697bef4566914d9717ac22222d05c40/src/main/resources/Documentation/cmd-rename.md#options
Reply all
Reply to author
Forward
0 new messages