Branch or PR analysis fails due to Key 'branch' was provided twice with parameters 'characteristic'

Using:

  • SonarQube Developer Edition 8.1.0.31237
  • Azure DevOps Server 2019.1
  • SonarQube extension v 4.8.1 for Azure DevOps Server 2019
  • Run Code Analysis task 4.8.0
  • SonarScanner for MSBuild 4.7.1

Had the same issue with SOnarQube 7.9.1, so upgraded to latest today.

Analysis is successful, however uploading report fails with “Key ‘branch’ was provided twice with parameters ‘characteristic’”.

Tail of the log contains:

...
10:34:47.810 INFO: CPD Executor CPD calculation finished (done) | time=31ms
10:34:48.139 INFO: Analysis report generated in 329ms, dir size=333 KB
10:34:48.248 INFO: Analysis report compressed in 109ms, zip size=104 KB
10:34:48.248 INFO: Analysis report generated in D:\BA\B1\_work\45\.sonarqube\out\.sonar\scanner-report
10:34:48.248 DEBUG: Upload report
10:34:48.295 DEBUG: POST 400 https://REPLACED/api/ce/submit?projectKey=TaaviHelpDesk&projectName=TaaviHelpDesk&characteristic=branch%3Dtaavi-test-pr&characteristic=branchType%3DBRANCH&projectKey=TaaviHelpDesk&projectName=TaaviHelpDesk&characteristic=branch%3Dtaavi-test-pr&characteristic=branchType%3DBRANCH | time=47ms
10:34:48.311 INFO: ------------------------------------------------------------------------
10:34:48.311 INFO: EXECUTION FAILURE
10:34:48.311 INFO: ------------------------------------------------------------------------
10:34:48.311 INFO: Total time: 14.271s
10:34:48.342 INFO: Final Memory: 23M/80M
10:34:48.342 INFO: ------------------------------------------------------------------------

So indeed the information is twice in the query string, but why?

Code Analysis is run on .net core projects.
The same build definition and analysis works on “master” branch, but not on any other branches or in PR.

Hi @tkoosaar and welcome to the community !

Do you have some kind of proxy between your SQ instance and Azure DevOps ? If yes, is there any kind of url rewrite somewhere ?

Thanks.

Mickaël

Hi,
Had to run for lunch, but fixed it just before leaving. The problem was with the service connection that was using http address. Some months ago we switched to https and enabled http to https rewrite/redirection. Once i changed to https address the PR / Branch analysis started to work.

Odd that the usual master branch analysis doesnt bring this issue out, but good hunch Mickaël Caro, i also started to believe its related to the url rewrite from http to https, cant think of any other thing causing such behavior.

Good to know !

My first guess will be that characteristic value can contains an equal sign, which is the basic separator or key/values in query string, so that should be something like that, not 100% sure though.

i am also facing the same issue, since i am using aws ec2 for jenkins and sonar, since i am able to genrate post the report from jenkins command mode, but the same is not working when run it on jenkins pipeline.

09:22:54.442 DEBUG: Upload report
09:22:54.522 DEBUG: POST 400 http://xx.xx.xx.xx:9000/api/ce/submit?projectKey=stage-branch-admin-Dsonar.projectName%3DGD-admin-Dsonar.language%3Dts-Dsonar.verbose%3Dtrue-Dsonar.sources%3D%2Fhome%2Fjenkins%2Fworkspace%2Fstage-branch-admin%2Fdist%2F-admin%2F-Dsonar.tests%3D%2Fhome%2Fjenkins%2Fworkspace%2Fstage-branch-admin%2Fdist%2F-admin%2F | time=79ms
09:22:54.530 DEBUG: eslint-bridge server will shutdown
09:22:54.717 DEBUG: stylelint-bridge server will shutdown
09:22:54.719 INFO: ------------------------------------------------------------------------
09:22:54.719 INFO: EXECUTION FAILURE