SonarCloudPrepare@1 task returning 403 in Azure DevOps

Hello,

All our scans have suddenly started failing this morning and are returning a HTTP 403 forbidden response. We’re pretty stumped as to why our scans have started failing as we have not changed anything at our end.

We’re using CI/CD pipelines in Azure Dev-Ops and it is failing on the SonarCloudPrepare@1 task. It is failing on both Microsoft hosted agents or our own self-hosted agents, and regardless of scanner mode being “MSBuild” or “CLI”.

403 indicates our organisation no longer has permissions to send scans to yourselves, but we’ve not changed anything on our side. Are there any logs on your side which could shed any light on this please?

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable: MSBuild and CLI
  • Languages of the repository: .NET and React

Logs from Azure DevOps:

2023-11-02T14:45:16.2829237Z ##[section]Starting: Prepare SonarCloud
2023-11-02T14:45:16.2981699Z ==============================================================================
2023-11-02T14:45:16.2982094Z Task         : Prepare Analysis Configuration
2023-11-02T14:45:16.2982410Z Description  : Prepare SonarCloud analysis configuration
2023-11-02T14:45:16.2982770Z Version      : 1.40.2
2023-11-02T14:45:16.2982901Z Author       : sonarsource
2023-11-02T14:45:16.2983084Z Help         : Version: 1.40.2. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
2023-11-02T14:45:16.2984055Z ==============================================================================
2023-11-02T14:45:17.5860497Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Keoghs_Keoghs.FunctionApp.Sample /o:REDACTED
2023-11-02T14:45:17.7028813Z SonarScanner for MSBuild 5.14
2023-11-02T14:45:17.7030711Z Using the .NET Framework version of the Scanner for MSBuild
2023-11-02T14:45:17.7685212Z Pre-processing started.
2023-11-02T14:45:17.7732915Z Preparing working directories...
2023-11-02T14:45:17.9826207Z 14:45:17.975  Updating build integration targets...
2023-11-02T14:45:18.1463828Z 14:45:18.131  Fetching analysis configuration settings...
2023-11-02T14:45:18.3908041Z 
2023-11-02T14:45:18.3909340Z ##[error]Unhandled Exception:
2023-11-02T14:45:18.4036646Z ##[error]System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 ().
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at SonarScanner.MSBuild.PreProcessor.WebClientDownloader.<TryDownloadIfExists>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.WebServer.SonarWebServer.<DownloadQualityProfile>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>(String[] args)
2023-11-02T14:45:18.4064425Z System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 ().
2023-11-02T14:45:18.4070957Z    at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2023-11-02T14:45:18.4139193Z    at SonarScanner.MSBuild.PreProcessor.WebClientDownloader.<TryDownloadIfExists>d__5.MoveNext()
2023-11-02T14:45:18.4241183Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4244300Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4245442Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4247338Z    at SonarScanner.MSBuild.PreProcessor.WebServer.SonarWebServer.<DownloadQualityProfile>d__11.MoveNext()
2023-11-02T14:45:18.4249667Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4251118Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4252604Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>d__9.MoveNext()
2023-11-02T14:45:18.4254385Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4255858Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4257215Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4258394Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>d__7.MoveNext()
2023-11-02T14:45:18.4259730Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4260621Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4261787Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4262879Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.MoveNext()
2023-11-02T14:45:18.4264340Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4265564Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4267187Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4268858Z    at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__10.MoveNext()
2023-11-02T14:45:18.4270424Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4271750Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4273263Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4274746Z    at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
2023-11-02T14:45:18.4276342Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4277667Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4279219Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4281870Z    at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
2023-11-02T14:45:18.4283420Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4284761Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4302479Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4309564Z    at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
2023-11-02T14:45:18.4313204Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4347630Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4355048Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4356249Z    at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
2023-11-02T14:45:18.4357775Z --- End of stack trace from previous location where exception was thrown ---
2023-11-02T14:45:18.4358921Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2023-11-02T14:45:18.4360068Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2023-11-02T14:45:18.4361090Z    at SonarScanner.MSBuild.Program.<Main>(String[] args)
2023-11-02T14:45:18.4370642Z ##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
2023-11-02T14:45:18.4376332Z ##[section]Finishing: Prepare SonarCloud

Hi,

If nothing changed, then it sounds like something expired. Quite likely it was your Azure DevOps PAT.

 
HTH,
Ann

Hi Ann,

Thanks for the suggestion. We’ve created a new PAT token from Azure Dev Ops and gave it read/write access for the “Code” scope as suggested in this article: Azure DevOps | SonarCloud Docs

…but it is still failing unfortunately. Do you have other suggestions please? Maybe additional scopes in the PAT token?

Hi,

Is it possible you have a different PAT configured at the project level?

 
Ann

Hello Andy,

I’ve started getting the same problem that you’re describing.

I’ve tried replacing the PAT for the organisation several times and even added one for the project but it made no difference for me.

Did replacing your PAT work for you?

Cheers

Ross