10.0 analysis failure: "Sequence contains more than one matching element" error on profile search

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Recently upgrade to v10
  • how is SonarQube deployed: zip, Docker, Helm
    Zip
  • what are you trying to achieve
    Running quality checks from Azure DevOps
  • what have you tried so far to achieve this
    It was working fine prior to a recent upgrade then without anything else changing we got the following error when trying to run code analysis from an Azure DevOps build
    Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
00:03:35.683  Fetching analysis configuration settings...
##[error]00:03:37.015  Failed to request and parse 'https://ourdomain/api/qualityprofiles/search?projectKey=ourproject': Sequence contains more than one matching element
00:03:37.015  Failed to request and parse 'https://ourdomain/api/qualityprofiles/search?projectKey=ourproject': Sequence contains more than one matching element

##[error]Unhandled Exception:
##[error]System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass6_0.<TryGetQualityProfile>b__0()
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func`1 op, String url, Action`1 onError)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.TryGetQualityProfile(String projectKey, String projectBranch, String organization, String language, String& qualityProfileKey)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, IDictionary`2& serverSettings, List`1& analyzersSettings)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
   at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
   at SonarScanner.MSBuild.BootstrapperClass.Execute()
   at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
   at SonarScanner.MSBuild.Program.Main(String[] args)
System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass6_0.<TryGetQualityProfile>b__0()
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func`1 op, String url, Action`1 onError)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.TryGetQualityProfile(String projectKey, String projectBranch, String organization, String language, String& qualityProfileKey)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, IDictionary`2& serverSettings, List`1& analyzersSettings)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
   at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
   at SonarScanner.MSBuild.BootstrapperClass.Execute()
   at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)

##[error]The process 'D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
Finishing: Prepare Analysis Configuration

Note that it seems a similar error to that described in the following issue which my reading of suggests there were multiple profiles for C# (one for .Net Core the other for .Net Framework) but that doesn’t seem to be the case for us unless mistaken

Hello @petercli ,

Welcome to the community!

It seems like you are using an old .NET ms build scanner which is no longer compatible with current SQ version.

In the recent version of SonarQube 10.0, the deprecated parameter projectKey of this Web Service https://ourdomain/api/qualityprofiles/search?projectKey=ourproject has been dropped in favour of project.

Though latest version of scanner have it fixed. Could you please use the latest version of scanner? I believe it should resolve your issue.

Let me know if you have more questions.

Best,
Jacek

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.