branchType switching SHORT to LONG midrun

Hi,

We’re trying to mark branches matching (rel-|ato_sonar_fixes).* as long lived branches.

To test this, we create new branches every time; but during the run we are seeing

L144

15:15:11.307 DEBUG: Created analysis Analysis[uuid=0a047d7b-11e6-4394-9a71-26c31124f654, branchId=a7a1f756-61b9-408d-add5-7dc4b77d39ba, branchType=short, newCodePeriod=null]

L47287

15:27:27.280 DEBUG: --> POST https://sonarcloud.io/api/ce/submit?organization=XXXXXXX&projectKey=XXXXXXX&projectName=XXXXXXX&characteristic=branch%3Drel-1.22_ato_scan_5&characteristic=branchType%3DLONG (5184233-byte body)

15:27:40.227 DEBUG: <-- 200 https://sonarcloud.io/api/ce/submit?organization=XXXXXXX&projectKey=XXXXXXX&projectName=XXXXXXX&characteristic=branch%3Drel-1.22_ato_scan_5&characteristic=branchType%3DLONG (12947ms, 44-byte body) 

15:27:40.229 INFO: Analysis report uploaded in 12951ms 

15:27:40.230 DEBUG: Report metadata written to /__w/<projectname>/<projectname>/.scannerwork/report-task.txt 

15:27:40.230 INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=XXXXXXXXX&branch=rel-1.22_ato_scan_5

On the api/project_branches page after the run is complete.

Anyone have ideas of the cause or a workaround?

Note: we have 2 existing long-lived branches: master and an old ato_sonar_fixes_2branch. But nothing else has registered as a long lived branch.

Thanks in advance!

Also all new affected branches in sonarqube show this in the sonarqube cloud UI

eventhough the github actions say the report was complete and uploaded successfully

Hey there.

This looks a lot like Invalid branch type 'SHORT'. Branch 'develop' already exists with type 'LONG' - #8 by pconnor, and we’re looking into it!

Thanks!

Thanks!

Edit: Actually @Colin, I’m not entirely sure it’s the same issue ?

It appears that the pipeline is attempting to publish analysis results for the develop branch as a short-lived (PR) branch, but this branch already exists in SonarCloud as a long-lived branch.

We’re doing this with a “new” created branch with a fresh commit every time. I’ll continue reading the thread though, looks like some other people are commenting there….

##[error]Task failed with status FAILED, Error message: Invalid branch type 'SHORT'. Branch 'releases/system-text-json-vulnerability-fix' already exists with type 'LONG'. 

^ Unfortunately, we are not getting a message like this in our logs. I searched our raw logs for any message containing the strings ”Invalid branch type” or “already exists with type" and did not find it.

2025-10-03T15:27:40.2308937Z 15:27:40.230 INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=XXXXX&branch=rel-1.22_ato_scan_5
2025-10-03T15:27:40.2309988Z 15:27:40.230 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2025-10-03T15:27:40.2310796Z 15:27:40.230 INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AZmqr53cpwrM74IEMiuP
2025-10-03T15:27:40.2311363Z 15:27:40.230 INFO: ------------- Upload SCA dependency files
2025-10-03T15:27:40.7623952Z 15:27:40.762 DEBUG: --> GET https://api.sonarcloud.io/analysis/sensor-cache/prepare-write?organization=XXXXX&project=XXXXX&branch=rel-1.22_ato_scan_5
2025-10-03T15:27:41.1697570Z 15:27:41.169 DEBUG: <-- 200 https://api.sonarcloud.io/analysis/sensor-cache/prepare-write?organization=XXXXX&project=XXXXX&branch=rel-1.22_ato_scan_5 (407ms, unknown-length body)
2025-10-03T15:27:41.1714520Z 15:27:41.170 DEBUG: --> PUT https://analysis-sensorcache-eu-central-1-prod.s3.eu-central-1.amazonaws.com/<I removed the path/creds from here> (8094646-byte body)
2025-10-03T15:27:44.3089932Z 15:27:44.307 DEBUG: <-- 200 OK https://analysis-sensorcache-eu-central-1-prod.s3.eu-central-1.amazonaws.com/<I removed the path/creds from here> (3137ms, 0-byte body)
2025-10-03T15:27:44.3097198Z 15:27:44.307 INFO: Sensor cache published successfully
2025-10-03T15:27:44.3097768Z 15:27:44.308 INFO: Inferred api base url 'https://api.sonarcloud.io' from host url 'https://sonarcloud.io'.
2025-10-03T15:27:44.3098556Z 15:27:44.308 DEBUG: Architecture analysis is disabled
2025-10-03T15:27:44.3100436Z 15:27:44.309 DEBUG: Post-jobs : 
2025-10-03T15:27:44.3519233Z 15:27:44.351 INFO: Analysis total time: 12:35.956 s
2025-10-03T15:27:44.3529352Z 15:27:44.352 INFO: ------------------------------------------------------------------------
2025-10-03T15:27:44.3529791Z 15:27:44.352 INFO: EXECUTION SUCCESS
2025-10-03T15:27:44.3530254Z 15:27:44.352 INFO: ------------------------------------------------------------------------
2025-10-03T15:27:44.3530663Z 15:27:44.352 INFO: Total time: 12:39.447s
2025-10-03T15:27:44.4472948Z 15:27:44.446 INFO: Final Memory: 343M/1336M
2025-10-03T15:27:44.4473618Z 15:27:44.446 INFO: ------------------------------------------------------------------------

Just in case, here’s everything after ANALYSIS SUCCESSFUL before we start the github workflow cleanup steps.

Edit: The following ignore the following, see the end of this thread.

As an update for anyone else who might run into this, we manually set the branch name to get this to work. Our github action now looks like this:

      - name: Run Sonar Scanner
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: |
          if [ "${{ github.event_name }}" = "push" ]; then
            echo "Running branch analysis with explicit branch name"
            sonar-scanner -X -Dsonar.branch.name=${{ github.ref_name }}
          else
            echo "Running PR analysis (auto-detected)"
            sonar-scanner -X 
          fi

Previously it was just sonar-scanner -X.

There are other related settings you may need to set (like target branch) but we don’t need them for now

Links that might be useful:

https://docs.sonarsource.com/sonarqube-cloud/enriching/branch-analysis-setup#under-the-hood
https://docs.sonarsource.com/sonarqube-cloud/enriching/branch-analysis-setup#target-branch
https://docs.sonarsource.com/sonarqube-cloud/enriching/branch-analysis-setup#issue-synchronization

Hello @f-barry,

I confirm the error you had was similar to the other thread (the error is server-side so it’s normal you didn’t find it in the scanner logs).

Were you setting the long-living branch pattern in the organization settings (and not at the project level)? If so that could explain the error, and it has now been fixed.

Thanks for the update

I am not sure; I was mostly testing with the org-level regex, but the person before me might have tested at the project level. I remember modifying the project-level regex at least once.

May test when I have more time to roll back to this issue, but probably not this week.

Thank you for the confirmation.
It may have been incidental that it started working after you provided the branch name in sonar.branch.name if you changed the project-level regex at the same time (I can’t explain why your workaround would change the branch-type detection behavior).

Confirmed that reverting my change doesn’t affect anything - you’re right