Dart sonar scan fails randomly

Github action pipeline fails, sometimes the scan command succeeds, but fails on the Quality Gate with 404

  • ALM used GitHub
  • CI system used Github Actions
  • Scanner command used when applicable (private details masked)

      - name: SonarQube Scan
        uses: SonarSource/sonarqube-scan-action@v6
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        with:
          args: >
            -Dsonar.projectKey=xxxxxxxx_flutter
            -Dsonar.organization=xxxxxxxx
            -Dsonar.host.url=https://sonarcloud.io
            -Dsonar.token=${{ secrets.SONAR_TOKEN }}
            -Dsonar.sources=lib
            -Dsonar.exclusions=**/*.g.dart,**/*.gen.dart,**/*.freezed.dart,**/*.mocks.dart,**/*.tailor.dart,**/*.config.dart,**/*.realm_schema.dart,**/base*.dart,**/constants.dart,**/*constant.dart,**/__test*__/**,**/__mock*__/**,**/presentation/**,lib/gen/assets.gen.dart,lib/src/utils/iterable.dart
            -Dsonar.tests=test
            -Dsonar.dart.lcov.reportPaths=coverage/lcov.info
      - name: SonarQube Quality Gate check
        id: sonarqube-quality-gate-check
        uses: sonarsource/sonarqube-quality-gate-action@v1.2.0
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        with:
          pollingTimeoutSec: 600
  • Languages of the repository
    • dart
    • flutter
  • Error observed: no error but quality gate fails

11:27:17.298 INFO  Branch name: master, type: long-lived
11:27:17.323 INFO  Preprocessing files...
11:27:18.089 INFO  2 languages detected in 324 preprocessed files (done) | time=762ms
11:27:18.091 INFO  264 files ignored because of inclusion/exclusion patterns
11:27:18.092 INFO  0 files ignored because of scm ignore settings
11:27:18.181 INFO  Loading plugins for detected languages
11:27:18.183 INFO  Load/download plugins
11:27:18.511 INFO  Load/download plugins (done) | time=331ms
11:27:18.555 INFO  Load project repositories
11:27:18.873 INFO  Load project repositories (done) | time=318ms
11:27:18.877 INFO  Indexing files...
11:27:18.878 INFO  Project configuration:
11:27:18.878 INFO    Excluded sources: **/*.g.dart, **/*.gen.dart, **/*.freezed.dart, **/*.mocks.dart, **/*.tailor.dart, **/*.config.dart, **/*.realm_schema.dart, **/base*.dart, **/constants.dart, **/*constant.dart, **/__test*__/**, **/__mock*__/**, **/presentation/**, lib/gen/assets.gen.dart, lib/src/utils/iterable.dart, **/build-wrapper-dump.json
11:27:18.912 INFO  324 files indexed (done) | time=34ms
11:27:18.921 INFO  Quality profile for dart: Sonar way - xxxxxxxx
11:27:18.921 INFO  Quality profile for json: Sonar way
11:27:18.921 INFO  ------------- Run sensors on module xxxxxxxx_flutter
11:27:18.947 INFO  Load metrics repository
11:27:19.129 INFO  Load metrics repository (done) | time=181ms
11:27:19.139 INFO  Sensor cache enabled
11:27:19.141 INFO  Load sensor cache
11:27:19.455 INFO  Load sensor cache (404) | time=314ms
11:27:19.793 INFO  Sensor JaCoCo XML Report Importer [jacoco]
11:27:19.795 INFO  'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
11:27:19.798 INFO  No report imported, no coverage information will be imported by JaCoCo XML Report Importer
11:27:19.798 INFO  Sensor JaCoCo XML Report Importer [jacoco] (done) | time=5ms
11:27:19.798 INFO  Sensor IaC GitHub Actions Sensor [iacenterprise]
11:27:19.803 INFO  There are no files to be analyzed for the GitHub Actions language
11:27:19.803 INFO  Sensor IaC GitHub Actions Sensor [iacenterprise] (done) | time=6ms
11:27:19.803 INFO  Sensor Dart Coverage [dart]
11:27:19.808 INFO  Analysing [/home/runner/work/flutter/Flutter/coverage/lcov.info]
11:27:19.918 INFO  Sensor Dart Coverage [dart] (done) | time=115ms
11:27:19.918 INFO  Sensor IaC CloudFormation Sensor [iac]
11:27:19.930 INFO  There are no files to be analyzed for the CloudFormation language
11:27:19.931 INFO  Sensor IaC CloudFormation Sensor [iac] (done) | time=13ms
11:27:19.931 INFO  Sensor IaC cfn-lint report Sensor [iac]
11:27:19.936 INFO  Sensor IaC cfn-lint report Sensor [iac] (done) | time=3ms
11:27:19.936 INFO  Sensor IaC Docker Sensor [iac]
11:27:19.940 INFO  There are no files to be analyzed for the Docker language
11:27:19.941 INFO  Sensor IaC Docker Sensor [iac] (done) | time=7ms
11:27:19.942 INFO  Sensor IaC hadolint report Sensor [iac]
11:27:19.944 INFO  Sensor IaC hadolint report Sensor [iac] (done) | time=3ms
11:27:19.946 INFO  Sensor IaC Azure Resource Manager Sensor [iac]
11:27:19.948 INFO  There are no files to be analyzed for the Azure Resource Manager language
11:27:19.949 INFO  Sensor IaC Azure Resource Manager Sensor [iac] (done) | time=3ms
11:27:19.952 INFO  Sensor Java Config Sensor [iac]
11:27:19.963 INFO  There are no files to be analyzed for the Java language
11:27:19.963 INFO  Sensor Java Config Sensor [iac] (done) | time=10ms
11:27:19.963 INFO  Sensor IaC JSON Sensor [iacenterprise]
11:27:19.963 INFO  Sensor IaC JSON Sensor [iacenterprise] (done) | time=1ms
11:27:19.964 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise]
11:27:19.978 INFO  Available processors: 2
11:27:19.978 INFO  Using 2 threads for analysis.
11:27:21.037 INFO  Start fetching files for the text and secrets analysis
11:27:21.044 INFO  Using Git CLI to retrieve untracked files
11:27:21.129 INFO  Retrieving language associated files and files included via "sonar.text.inclusions" that are tracked by git
11:27:21.131 INFO  Starting the text and secrets analysis
11:27:21.133 INFO  324 source files to be analyzed for the text and secrets analysis
11:27:22.027 INFO  324/324 source files have been analyzed for the text and secrets analysis
11:27:22.027 INFO  Start fetching files for the binary file analysis
11:27:22.028 INFO  There are no files to be analyzed for the binary file analysis
11:27:22.030 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise] (done) | time=2066ms
11:27:22.030 INFO  Sensor Dart [dart]
11:27:39.792 INFO  Sensor Dart [dart] (done) | time=17761ms
11:27:39.796 INFO  ------------- Run sensors on project
11:27:39.934 INFO  Sensor Zero Coverage Sensor
11:27:39.948 INFO  Sensor Zero Coverage Sensor (done) | time=14ms
11:27:39.950 INFO  ------------- Gather SCA dependencies on project
11:27:40.124 INFO  SCM Publisher SCM provider for this project is: git
11:27:40.126 INFO  SCM Publisher 316 source files to be analyzed
11:27:43.830 INFO  SCM Publisher 316/316 source files have been analyzed (done) | time=3702ms
11:27:43.844 INFO  CPD Executor 81 files had no CPD blocks
11:27:43.845 INFO  CPD Executor Calculating CPD for 118 files
11:27:43.888 INFO  CPD Executor CPD calculation finished (done) | time=41ms
11:27:45.071 INFO  Analysis report generated in 1155ms, dir size=1 MB
11:27:45.416 INFO  Analysis report compressed in 346ms, zip size=665 KB
11:27:47.813 INFO  Analysis report uploaded in 2393ms
11:27:47.813 INFO  ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=xxxxxxxx-flutter&branch=master
11:27:47.813 INFO  Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
11:27:47.813 INFO  More about the report processing at https://sonarcloud.io/api/ce/task?id=AZmaYO1WdQwQnJW7SrrL
11:27:47.818 INFO  ------------- Upload SCA dependency files
11:27:47.908 INFO  Analysis total time: 35.146 s
11:27:47.911 INFO  SonarScanner Engine completed successfully
11:27:48.241 INFO  EXECUTION SUCCESS
11:27:48.242 INFO  Total time: 44.222
Run sonarsource/sonarqube-quality-gate-action@v1.2.0
  with:
    pollingTimeoutSec: 600
    scanMetadataReportFile: .scannerwork/report-task.txt
  env:
    FLUTTER_VERSION: 3.35.0
    FLUTTER_CHANNEL: stable
    FLUTTER_ROOT: /opt/hostedtoolcache/flutter/stable-3.35.0-x64
    PUB_CACHE: /home/runner/.pub-cache
    pythonLocation: /opt/hostedtoolcache/Python/3.13.7/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.13.7/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.13.7/x64/lib
    SONAR_TOKEN: ***
Run $GITHUB_ACTION_PATH/script/check-quality-gate.sh ".scannerwork/report-task.txt" "600"
  $GITHUB_ACTION_PATH/script/check-quality-gate.sh ".scannerwork/report-task.txt" "600"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    FLUTTER_VERSION: 3.35.0
    FLUTTER_CHANNEL: stable
    FLUTTER_ROOT: /opt/hostedtoolcache/flutter/stable-3.35.0-x64
    PUB_CACHE: /home/runner/.pub-cache
    pythonLocation: /opt/hostedtoolcache/Python/3.13.7/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.13.7/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.7/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.13.7/x64/lib
    SONAR_TOKEN: ***
.
curl: (22) The requested URL returned error: 404
Error: Process completed with exit code 22.
  • Steps to reproduce
    • run the github action

Hello,

To use sonarsource/sonarqube-quality-gate-action, you should set the SONAR_HOST_URL variable to https://sonarcloud.io. While this task was originally designed for SonarQube Server, configuring the host URL as described should allow it to work with SonarQube Cloud as well.