New issue
Advanced search Search tips

Issue 10106 link

Starred by 1 user

Issue metadata

Status: Released
Owner: ----
Closed: Dec 4



Sign in to add a comment

Can't update project rights with REST ACCESS API

Reported by florian....@allegorithmic.com, Nov 28

Issue description

Affected Version: 2.15.2

What steps will reproduce the problem?
1. With a Gerrit Administrator account and his HTTP password
2. With a test project 'test-project' with some group permissions 
2. Get permissions on this project:
   $ curl -v --user 'XXXX:YYYY' 'https://gerrit/a/projects/test-project/access'
3. Create a file test.json to remove an existing permission (see attached file)
4. Change permissions:
   $ curl -v --user 'YYYY:XXXX' --header "Content-Type: application/json" -d @test.json 'https://gerrit/a/projects/test-project/access' 

What is the expected output?
HTTP 200 with updated permissions.

What do you see instead?
HTTP 400 Invalid application/json in request

Please provide any additional information below.
- And empty JSON file ({}), or JSON file with verb only but no permissions change, return existing permission (expected behavior)
- This test is close to example in documentation: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#set-access
- This test use 'remove', but 'add' fail too when I test it.
- Attached file 'test.json' contains action sent to REST API.
- Attached file 'result-GET.txt' contains result of GET request.
- Attached file 'result-POST.txt' contains result of POST request.

 
result-GET.json
2.3 KB View Download
result-POST.txt
923 bytes View Download
Expected test.json (not empty one ...)
test.json
193 bytes View Download
I am not aware of PolyGerrit use of the REST API.

With this information, I run on PolyGerrit page "https://gerrit/admin/projects/internship-projects,access" and found a "This is currently in read only mode. To modify content, go to the Old UI".

Trying with current 2.16, this page is available.

So this REST API is documented on 2.15, but not used by PollyGerrit. So, should we close this report with a workaroung "Update to 2.16" ?


Thanks,
Doing some more tests, new json file 'test-2.16-ok.json' is working on 2.16. This test was built by comparing documentation example with real calls made by PollyGerrit.

JSON format must be without list (remove [] after action), look like an outdated example in documentation ?

About 2.15.2, this test fail again but with another error after JSON data mapping:
ERROR com.google.gerrit.httpd.restapi.RestApiServlet : Error in POST /a/projects/internship-projects/access
java.lang.NullPointerException: action
	at com.google.gerrit.common.data.PermissionRule.setAction(PermissionRule.java:48)
	at com.google.gerrit.server.project.SetAccessUtil.getAccessSections(SetAccessUtil.java:103)
	at com.google.gerrit.server.project.SetAccess.apply(SetAccess.java:82)
	at com.google.gerrit.server.project.SetAccess.apply(SetAccess.java:45)
	at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.java:405)

For us, moving to 2.16 and fix documentation is a good option.
test-2.16-ok.json
159 bytes View Download
Components: -PolyGerrit
Status: ChangeUnderReview (was: New)
Oh, that's annoying.  Thanks for tracking this down and fixing the documentation.

Labels: FixedIn-2.15.8
Status: Submitted (was: ChangeUnderReview)
Project Member

Comment 7 by luca.mil...@gmail.com, Dec 21

Labels: FixedIn-2.16.2
Status: Released (was: Submitted)
Labels: FixedIn-2.16.3

Sign in to add a comment