Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Either 'id' or 'name' must be provided #274

Closed
zied-ellouze opened this issue Aug 13, 2021 · 12 comments · Fixed by #275 or #279
Closed

[ERROR] Either 'id' or 'name' must be provided #274

zied-ellouze opened this issue Aug 13, 2021 · 12 comments · Fixed by #275 or #279
Labels
bug Something isn't working done This issue was solved but not merged in master
Milestone

Comments

@zied-ellouze
Copy link

Describe the bug

Impossible to generate report with command line

To reproduce

Execute command :
java -jar sonar-cnes-report-3.3.1.jar -t 3f91c4c533c4cbda367cb21eb48dbb5fd10b07cd -s https://host -p projectid -b branch
SonarQube URL: https://host
SonarQube online: true
Detected SonarQube version: 7.9.4
[ERROR] Either 'id' or 'name' must be provided

I tested with several options :

  • with author : -a
  • without branch : -d

But everytime i have some error

User environment

  • OS: Windows 10
  • Project version: 3.3.1
  • Java : 11.0.11
@zied-ellouze zied-ellouze added the bug Something isn't working label Aug 13, 2021
@ErwanGauduchon
Copy link
Contributor

Hi @zied-ellouze, thank you for your feedback !

The error you have seems to come from an API call that is not executed correctly.
The reason may be that a special character is present in your project id/quality profiles names/quality gate name which results in a truncated HTTP request.
Can you tell me if there is any special character in these components ?
If it is the case, I suggest you to remove them.
We don't plan to release another patch of the version 3.3 of CNES report because we are working on a new version compatible with SQ 8.9 so this is the only fix that I can propose.

@zied-ellouze
Copy link
Author

Hi @ErwanGauduchon
Thank you for response
project id contain dot (.) and dash (-), can that be a problem?
Thank you

@Sancretor
Copy link
Contributor

Hi @zied-ellouze

I've just installed SonarQube 7.9.6 on Windows 10 but I'm not able to reproduce your error.
I tried to put as many special char inside project id, quality profile id and quality gate id, but still ...
So that's probably not an issue related to that.

Could you please have a look at your SonarQube logs while you're executing the CNES Report ?
If you see anything looking like an exception, please do consider sending us those logs.
Also, remember to remove any confidential information.

@zied-ellouze
Copy link
Author

Hi @Sancretor

I will ask the team manages SonarQube to check the Sonar logs.

SonarQube is installed on a Linux machine and the command I run it from a windows PC.

Here is the CNES Report log if it helps
cnesreport-0.log

@ErwanGauduchon
Copy link
Contributor

Hi @zied-ellouze

We looked at the logs you sent and the lines don't match the version 3.3.1 of CNES Report.
Are you sure you are using this one ? It may be another version or a fork.
The problem you have seems to come from a request to get one of your SonarQube server quality gates but we are unable to reproduce it.

@seb0uil
Copy link

seb0uil commented Aug 18, 2021

Hi,
I work with @zied-ellouze, and checked the pb on our sonarqube server.
Actually the pb is due to url encoding.
In our quality gate, some QG names have '%' in their name.
But in QualityGateProvider.java (L81) there is only:
i.getName().replace(" ", "%20")
instead of
UrlEncoder.urlEncodeString(i.getName())

@Sancretor
Copy link
Contributor

Sancretor commented Aug 18, 2021

Hi @seb0uil
Thanks for your feedback, and this ugly historical piece of code that still survives .... we'll fix that.

Actually, you found an error inside the code, but it's not the one @zied-ellouze is facing.
In your case, SonarQube will just respond that it cannot find any Quality Gate matching this name, because the name is not well formatted (we reproduced the error you found).

But here, SonarQube says that the "name" parameter is missing, which is impossible because this parameter is hardcoded in the requests properties.
Also, that does not explain why lines are not matching the codebase of version 3.3.1. Maybe you're using a fork or a modified version and we can't debug it properly.
While we are not 100% sure you're using our 3.3.1 version of the CNES Report, it will be hard to help you with this error.

@seb0uil
Copy link

seb0uil commented Aug 18, 2021

No, actually it's the same issue.
In my example, the QG name is '10% duplications', wich is badly encoded in '10%%20duplications'
With this name, the sonarqube answer is not the name is incorrect, but {"errors":[{"msg":"Either 'id' or 'name' must be provided"}]} as you can see on https://sonarcloud.io/api/qualitygates/show?name=10%%20duplications , even if the QG doesn't exist.

In sonar-cnes-report, the name parameter is in the query, as you said, it's hardcoded, but due to the bad url encoding, sonar seems to misinterpret the url.

In my case, i compile the 3.3.1 tag using JDK 11. I guess @zied-ellouze use the same, but the log he provided are not sonarqube logs, but only logs from command line sonar-cnes-report.

@Sancretor
Copy link
Contributor

Sancretor commented Aug 18, 2021

Oh... OK I finally get it, sorry.
I did not understand that a space was following the % character.
Your analysis is right then.

But the 3.3.1 version is the last release we will produce for SonarQube 7.9, and we are working on the 8.9 LTS compatibility.
So the plan would not be to produce a 3.3.2 with this fix, but rather integrate it inside 4.0.0 for SQ 8.9, because 7.9 will soon be deprecated and this new fix version will be refused on SQ Marketplace...
Do you plan to upgrade your SonarQube instance soon by any chance ?

@Sancretor Sancretor added this to the 4.0.0 milestone Aug 18, 2021
@seb0uil
Copy link

seb0uil commented Aug 18, 2021

Do you plan to upgrade your SonarQube instance soon by any chance ?
We have to, I hope it'll be done soon.
For @zied-ellouze issue, we will just fix it by our own as i described previously

@Sancretor
Copy link
Contributor

Alright, thanks a lot for your understanding and your feedback.
The fix will be merged inside the next release, so after your SonarQube upgrade you should not face it again.

@zied-ellouze
Copy link
Author

Thank you @Sancretor @seb0uil : @seb0uil solution resolved the error and I was able to generate the reports.

@ErwanGauduchon : I got the wrong version when I launched the command for logs. I tried several versions

@Sancretor Sancretor linked a pull request Aug 19, 2021 that will close this issue
12 tasks
@ErwanGauduchon ErwanGauduchon added the done This issue was solved but not merged in master label Aug 19, 2021
@Sancretor Sancretor mentioned this issue Aug 27, 2021
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done This issue was solved but not merged in master
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants