Sonar scanner fails with java.nio.file.InvalidPathException

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube: Version 9.6.1 (build 59531)

We just run sonar using mvn sonar:sonar in Gitlab CI. I know there’s a 4.7 release for sonar-scanner-cli, but I’m not sure how to bump our version to that as we didn’t configure the version anywhere. I doubt that the 4.7 would fix the issue though.

  • what are you trying to achieve
    Just trying to run Java tests and have sonar analyze the coverage.
  • what have you tried so far to achieve this
    Run sonar using mvn sonar:sonar, we’ll see whether we can ignore the test from sonar for now.

We have a test that tests our encoding so it uses a very fancy file name. It seems like SonarScanner’s git integration can’t handle the filename. The used filename is as follows

EncodingTest/%20 fo%lder/It's$a%30me Mariomariposónمرحبا مارك.ホットドッグが好き/It's$a%30me Mario.vhdl

It contains: spaces, characters that look like they’re already encoded (but that should be encoded once more), Arabic (Left-to-Right), and Japanese katakana, hiragana, and kanji. The error we receive is as follows (the ???? are printed as is in the console)

Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: com.sigasi.hdt.exampleprojects/vhdl-projects/EncodingTest/%20 fo%lder/It's$a%30me Mariomaripos?n????? ????.?????????/It's$a%30me Mario.vhdl` `	at java.base/sun.nio.fs.UnixPath.encode(` `	at java.base/sun.nio.fs.UnixPath.<init>(` `	at java.base/sun.nio.fs.UnixFileSystem.getPath(` `	at java.base/java.nio.file.Path.resolve(` `	at org.sonar.scm.git.GitScmProvider.lambda$branchChangedFiles$1(` `	at java.base/$3$1.accept(` `	at java.base/$2$1.accept(` `	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(` `	at java.base/` `	at java.base/` `	at java.base/$ReduceOp.evaluateSequential(` `	at java.base/` `	at java.base/` `	at org.sonar.scm.git.GitScmProvider.branchChangedFiles(` `	at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded(` `	at org.sonar.scanner.scm.ScmChangedFilesProvider.provide(` `	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)` `	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(` `	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(` `	at java.base/java.lang.reflect.Method.invoke(` `	at` `	... 93 more


Thank you for reaching out.

We tried our best to mimic a scan using a similar folder and file name and were able to scan successfully. We are using the exact same version of the scanner, sonarqube, and Postgres (with docker):

I would be curious to know how your Gitlab CI runner is configured, and if the configuration supports UTF-8 encoding. In addition, could you provide a full log of the scanner for us to do a deeper investigation?

Many thanks.