ERROR: Malformed input or input contains unmappable characters
Asked Answered
G

2

6

I am running the sonar scanner for my project with (-Dsonar.sourceEncoding=UTF-8) but I am getting the following error.

INFO: SonarQube Scanner 3.2.0.1227

INFO: SonarQube server 8.9.7

INFO: Default locale: "en_US", source code encoding: "UTF-8"

WARN: SonarScanner will require Java 11 to run, starting in SonarQube 9.x

...

ERROR: Error during SonarQube Scanner execution

ERROR: Malformed input or input contains unmappable characters: src/main/html/images/T??cnica.jpg

The word has a tilde.I have tried to exclude the .jpg files and the folder where this file is located but I still get the same error. Any solution?

Solution:

Inside the Jenkins container run the following commands to change the locale

apt-get update && apt-get install -y locales
sed -i '/es_ES.UTF-8/s/^# //g' /etc/locale.gen
locale-gen
update-locale LC_ALL="es_ES.UTF-8"
Grosmark answered 3/5, 2022 at 12:44 Comment(2)
Please provide enough code so others can better understand or reproduce the problem.Tion
When I run sonarscanner I get the following error. ERROR: Malformed input or input contains unmappable characters: src/main/html/images/T??cnica.jpg I am using the UTF8 encodingMccloskey
D
5

For me, adding this to the Dockerfile was enough:

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
Desdamona answered 4/1, 2023 at 10:46 Comment(1)
Thanks, it worked for me as well. Tried sonar.sourceEncoding and sonar.exclusions but none of those worked. After many hours of searching and hit/try found this and worked.Insalivate
U
0

TL;DR: add LC_ALL: "C.UTF-8" to your YAML action on GitHub CI.


This question is relatively old, but yesterday I faced a very similar issue with Sonar: my GitHub action with SonarQube check was crashing with the following error:

11:31:28.355 ERROR Error during SonarScanner CLI execution
java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: path/to/the/file/file-with-umlaut-ä.html

Even though my Sonar server has a LC_ALL=en_US.UTF-8 locale. And since I haven't changed anything, the usual suspect was the GitHub action itself. I use the master branch, which was recently updated to the v3.0.0. See the action release history here.

But then I spotted the option to add LC_ALL into my tests.yml action file, like this:

    - name: Run SonarQube scan
      uses: sonarsource/sonarqube-scan-action@master
      env:
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
        LC_ALL: "C.UTF-8"

After explicitly defining the LC_ALL, everything started to work again.

Unlike answered 13/8, 2024 at 14:5 Comment(1)
thanks, that is exactly the issue and solution I needLeucas

© 2022 - 2025 — McMap. All rights reserved.