Sonar scanner error since v4

SonarQube Server version: 10.3
Sonar scanner version: 4.0.1

Since version 4.0 was published we are receiving the following error in every scan attempt, at the very beginning of the scan, for some of our projects:

[INFO] Bootstrapper: Retrieving info from “package.json” file
[ERROR] Bootstrapper: An error occurred: Error: slugify: string argument expected

After some testing we found that the problem is happening when the scan is processing a ‘package.json’ file that is found in the root of the working directory. That package.json doesn’t contains a name property, and we believe that the lack of that property is triggering the error in this line of the scanner:

params[‘sonar.projectKey’] = slugify(pkg.name, {
remove: invalidCharacterRegex,
});

Could you please check if that’s the case and hopefully fix the processing of the package.json?

Thanks in advance.

Best regards,
Fran Sastre

2 Likes

Hey there @fransastre!

Just to be sure I understand – are you setting sonar.projectKey somewhere else? LIke a sonar-project.properties file or a command line parameter (-Dsonar.projectKey=...)

Hello Collin,
We have a sonar-project.properties file that contains the project key & name, but according to our tests, the issue appears always, no matter if you set project.key in the command line or in the sonar-project.properties. As soon as it starts processing the package.json that does not contains any name property it crashes.

Thanks! I’ll pass this onto our experts. Hold tight.

Hello @fransastre , it looks like indeed there is a limitation introduced by v4 where a package.json without a name entry will cause the scan to stop.

Thanks for pointing it out. I’ve created a ticket SCANNPM-41 that you can use to track our progress on the resolution of this,

Hope this helps
Benjamin

1 Like

Hi Benjamin,
Thank you very much for the prompt response.
We are looking forward for the next release.

Best,
Fran