Dotnet sonarscanner end fails with the java.nio.file.InvalidPathException

We have faced and error which were caused by the Cyrillic symbols in file names during the execution

# dotnet sonarscanner end
...
java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: tools/somedir/???????????? ?????????????????? ?????? ?????? 12.02.txt
...

We’re using docker mcr.microsoft.com/dotnet/sdk:5.0

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarScanner for MSBuild 5.9.2
Using the .NET Core version of the Scanner for MSBuild
INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.9.2/dotnet-sonarscanner/5.9.2/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
INFO: Project root configuration file: /builds/autofollow/fintarget/.sonarqube/out/sonar-project.properties
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.16 Debian (64-bit)
INFO: Linux 5.4.179-1.el7.elrepo.x86_64 amd64
INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.9.2/dotnet-sonarscanner/5.9.2/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
INFO: Analyzing on SonarQube server 9.5.0.56709
INFO: Default locale: "en_US", source code encoding: "UTF-8"
# locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
  • what are you trying to achieve
    Just complete the command
    # dotnet sonarscanner end
    without an error

  • what have you tried so far to achieve this
    We have tried to enforce UTF-8 coding for the Java with the:
    "export JAVA_OPTS="-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8"
    We have tried to rebuild the system locale
    We have tried to exclude the “tools/somedir” path with the -d:sonar.exclusions=dependency-check-report.*,tools/**/*.*,**/tools/**/*.* options

but still no luck

1 Like

Hey there.

I’m not surprised to hear something went awry with another character set.

It would be really helpful to know what the scanner was doing when it threw this error… so what was happening in the ... before the InvalidPathException :slight_smile:

Thanks!

1 Like

Thank you for the reply. Sorry, was not available to respond.
Well… actually not too much information before the exception, check it (I only masked some “private” information with ***:

$ dotnet sonarscanner end
SonarScanner for MSBuild 5.9.1
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
Calling the SonarScanner CLI...
INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.9.1/dotnet-sonarscanner/5.9.1/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
INFO: Project root configuration file: /builds/autofollow/fintarget/.sonarqube/out/sonar-project.properties
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.16 Debian (64-bit)
INFO: Linux 5.4.179-1.el7.elrepo.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.9.1/dotnet-sonarscanner/5.9.1/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
INFO: Project root configuration file: /builds/autofollow/fintarget/.sonarqube/out/sonar-project.properties
INFO: Analyzing on SonarQube server 9.5.0.56709
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=292ms
INFO: Server id: 86E1FA4D-AV_3CWdGVPLo9hr60r57
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: Load/download plugins (done) | time=8698ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 12.548s
INFO: Final Memory: 27M/744M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ClassRealm{javascript}-org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl': Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AnalysisTempFolder' defined in org.sonar.scanner.analysis.AnalysisTempFolderProvider: Unsatisfied dependency expressed through method 'provide' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DefaultInputProject' defined in org.sonar.scanner.scan.InputProjectProvider: Unsatisfied dependency expressed through method 'provide' parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProjectReactor' defined in org.sonar.scanner.scan.MutableProjectReactorProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.api.batch.bootstrap.ProjectReactor]: Factory method 'provide' threw exception; nested exception is java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /builds/autofollow/fintarget/tests/HS.Tests/Resources/???????? ?????????.txt

Thanks @yagza

It looks like the scanner is tripping up on this file name:

builds/autofollow/fintarget/tests/HS.Tests/Resources/??? ???.txt

Just to make sure – is this a real file that exists, or did you edit the file name (and add question marks) to redact the real file name?

Thanks you for the quick reply. I appreciate it.
Indeed, the file is the reason. I mentioned in the original post “We have faced and error which were caused by the Cyrillic symbols in file names during the execution”.

This is normal file BUT with the Cyrillic symbols in its name.

Please be noted that if I run (for instance) the command ls -la the result will be normal and the filename will be displayed as it is, without any question marks. I have tried running ls -la under the same user that was used to run the above dotnet commands.

Hey there.

Sorry, I did a bad job reading your full post and just focused on the stacktrace :man_facepalming: I’ll blame it on the holidays. :smiley:

I went ahead and tried scanning a file name with Cyrillic symbols – файл.txt… and it didn’t give me any trouble. I still couldn’t reproduce it even when following a colleague’s advice who debugged a similar issue.

Still… I would expect this is an issue of having the encoding set correctly. Where is it that are you adjusting the locale (and then running the locale command from)? Within the docker container, or only on the machine hosting the docker engine?

Oh, sorry my bad :frowning: I forgot to share the original environment. Must be the same reason… holidays. Merry Christmas btw :slight_smile:

It is a docker container. Let me share the whole original dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:5.0

WORKDIR /src

RUN apt update && apt upgrade -yq  && apt install -yq openjdk-11-jdk curl protobuf-compiler-grpc locales
RUN curl -sL https://deb.nodesource.com/setup_13.x | bash -
RUN apt update -yq && apt install -yq nodejs

RUN locale-gen "en_US.UTF-8"
RUN dpkg-reconfigure locales 

ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8

Hope it helpful.

I’m facing the same problem, can you help me?

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ProjectReactor’ defined in org.sonar.scanner.scan.MutableProjectReactorProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.api.batch.bootstrap.ProjectReactor]: Factory method ‘provide’ threw exception; nested exception is java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /home/jenkins/agent/workspace/Projeto-2024-Build-HML-teste/ProjetoTeste2024.UI/wwwroot/images/2024/desempenho/lider/n?o.svg