Protection of branch fails even after deleting old protection
What I do:
- I fork a repo using the API from a repo that has master branch protected to maintainers only
- I try to unprotect the branch using the API The call:
Started PUT "/api/v4/projects/ALPROTUTCALCULATOR%2Falprotutcalculator%2Ds6vikaut/repository/branches/master/unprotect" for XXX at 2020-11-10 09:13:17 +0000
The call suceeds(200 is the status code I guess):
"PUT /api/v4/projects/ALPROTUTCALCULATOR%2Falprotutcalculator%2Ds6vikaut/repository/branches/master/unprotect HTTP/1.1" 200 873 "" "Jersey/2.30.1 (HttpUrlConnection 15-ea)" -
- I try to protect the branch via API and only restrict it to Developers
Started POST "/api/v4/projects/ALPROTUTCALCULATOR%2Falprotutcalculator%2Ds6vikaut/protected_branches?name=master&push_access_level=30&merge_access_level=30" for XXX at 2020-11-10 09:13:17 +0000
{"time":"2020-11-10T09:13:18.021Z","severity":"INFO","duration_s":0.0347,"db_duration_s":0.01184,"view_duration_s":0.02286,"status":409,"method":"POST","path":"/api/v4/projects/ALPROTUTCALCULATOR%2Falprotutcalculator%2Ds6vikaut/protected_branches","params":[{"key":"name","value":"master"},{"key":"push_access_level","value":"30"},{"key":"merge_access_level","value":"30"}],"host":"XXX","remote_ip":"XXX, XXX, 127.0.0.1","ua":"Jersey/2.30.1 (HttpUrlConnection 15-ea)","route":"/api/:version/projects/:id/protected_branches","user_id":1,"username":"artemis","queue_duration_s":0.024244,"correlation_id":"rQPcwzremq7","meta.user":"artemis","meta.project":"ALPROTUTCALCULATOR/alprotutcalculator-s6vikaut","meta.root_namespace":"ALPROTUTCALCULATOR","meta.caller_id":"/api/:version/projects/:id/protected_branches"}
- My application throws an error, because renewing protection of branch master fails:
Caused by: org.gitlab4j.api.GitLabApiException: Protected branch 'master' already exists
First I expected that maybe I needed to wait for fork creation to finish. So I am asking gitlab about the status of the fork and I only proceed if the fork is fully created. But this did not help.
Btw. this happens in 2/400 cases so it is some kind of race condition i think.
What am I doing wrong? Is this a bug? Any idea what I can do about it? I can provide more info if needed(I can provide full log but if so I want to not do this public).
Edited by Alexander von Trostorff