Where can I find the "scanner logs" in the SonarQube Cloud UI?

Hi there!

I have started getting the following message at the top of my dashboard:

There are problems with file encoding in the source code. Please check the scanner logs for more details.

Were can I find those logs in SonarQube Cloud? I’m currently on the Team Plan.

Thanks in advance.

Hello @edufelipe. I believe it depends on the way how you run the analyzing. For Example we have those logs in Jenkins CI.

BTW see 2 issues that I reported recently about the warning with file encoding, maybe 1 of them affected you:

  1. Unexplainable warnings about encoding

  2. Suspicious multiple warnings about encoding on binary files

I’m not using Jenkins or any other CI. I’m using SonarQube Cloud connected to a repo on GitHub.

It is a paid plan. As far as I’m aware, Sonar is running the analyzing themselves, right?

Hey @edufelipe, it sounds like you’re using automatic analysis, could you please confirm this (your project > Administration > Analysis method)? If so, then you are right: the analysis runs on our side, and therefore you wouldn’t be able to access the logs, so we should word this warning differently.

Yes. That’s the case. I’m using automatic analysis. Is there a way for me to know what file is causing this warning?

Is there a way for me to at least know the file that is causing that warning to appear?

Hi @edufelipe,

Since you’re using automatic analysis, you won’t have direct access to the scanner logs, they run on our infrastructure. However, we can look into this on our end if you share the background task analysis ID, which you can find here:

  1. Go to your project in SonarQube Cloud
  2. Click Administration (project-level)
  3. Select Background Tasks
  4. Find the most recent completed analysis and click on it
  5. Copy the ID shown at the top (it looks like AZ8nc...)

Share that ID here and we can check the logs on our side to identify exactly which file is triggering the encoding warning.

Cheers,

Stevan

Hi Stevan,

The latest ID is AZ9c8AHIxY9nxyqMaT4s

Best regards,

Eduardo.

Hi @edufelipe,

I had a look at the logs from your latest analysis and found the cause of the warning.

The scanner is picking up binary files: PNGs, JPGs, fonts (TTF, WOFF, WOFF2), MP3s, MP4s, and other static assets in your server/static/, server/widgets/static/, and server/filebrowser/static/ directories. The default behavior is to attempting to read them as UTF-8 source code. Since they’re binary, it hits invalid characters on every one of them, which is what triggers the “problems with file encoding” warning.

The fix is to configure the scanner to skip those files. Since you’re using automatic analysis, you can do this by adding a .sonarcloud.properties file to the root of your repository with the following:

sonar.exclusions=**/*.png,**/*.jpg,**/*.jpeg,**/*.gif,**/*.ico,**/*.webp,**/*.ttf,**/*.woff,**/*.woff2,**/*.eot,**/*.mp3,**/*.mp4,**/*.gz

Alternatively, you can exclude by directory if you’d prefer:

sonar.exclusions=server/static/**,server/widgets/static/**,server/filebrowser/static/**,specs/**

This is the only place configuration changes can be made in Autoscan, there’s no UI for it, it has to go in .sonarcloud.properties at the repo root.

Once that file is committed and the next analysis runs, the binary files will be excluded and the warning should disappear.

Hope that helps.

Best regards,

Stevan

Hi Stevan!

I did just like you asked and added this to my config:

sonar.exclusions=\
  **/__pycache__/**,\
  **/.cache/**,\
  **/.env/**,\
  **/.eslintcache,\
  **/.venv/**,\
  **/*.crt,\
  **/*.csv,\
  **/*.eot,\
  **/*.gz,\
  **/*.ico,\
  **/*.ics,\
  **/*.jpg,\
  **/*.min.css,\
  **/*.min.js,\
  **/*.mp3,\
  **/*.mp4,\
  **/*.png,\
  **/*.ttf,\
  **/*.webp,\
  **/*.woff,\
  **/*.woff2,\
  **/bin/**,\
  **/dist/**,\
  **/graphql-types.ts,\
  **/nexus-typegen.ts,\
  **/node_modules/**,\
  **/pblib.cjs,\
  **/vendor/**

But still there is a warning on the scan that happened after it.

The ID of the scan is AZ9d3bWwAKW_8u2GJ57f

Would you mind checking it out and telling me what I have missed?

Best regards,

Eduardo.

Hi @edufelipe,

Looks like there’s one last one missing:

23:40:51.245 WARN  Invalid character encountered in file /tmp/clone1302560185406427388/server/static/img/loader.gif at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'

So, just add **/*.gif, and that should resolve the warnings.

Cheers,

Stevan

Perfect! Our project is finally free of warnings. Thanks for your support.