Error from + prefixed to org id

Hello,
We have experienced the same issue yesterday. I have tried rerunning the pipeline today, however the issue still persists:

Error 404 on https://api.sonarcloud.io/analysis/active-rules?organization=+xxx&project=yyy

Our current setup:

    - task: SonarCloudAnalyze@3
      displayName: 'Run Code Analysis'

    - task: SonarCloudPublish@3
      displayName: 'Publish Quality Gate Result'
1 Like

We got the same problem. Running and PAT token reset with full access does not help. The only option found is to skip the Sonar steps for WHOLE solution before fix get delivered. We’re going to track it status.

Another possible problem “Error 404 on https://api.sonarcloud.io/analysis/active-rules?organization=+ORGNAME&project=REPONAME”
Why is there a ‘+’ in the organization parameter? The default value for that is ‘ORGNAME’:

however ‘+’ represents a space in query string, so it will be " ORGNAME" which is not necessarily wrong if sonar handles it. From our side we are sending it without space. Maybe this is related to root cause. Please check it

Hi folks,

For people having the issue of the extra “+” in the organization query parameter, this seems to be a different issue than the original “/api/v2” issue.

I guess there is an extra space added somewhere, and I would like to understand the root cause to decide on the best fix.

Can you please describe your scanner setup? For example, are you using the SonarQube Cloud Azure Devops Extension? What is your scanner flavor (e.g. .NET, CLI, Maven)? How do you pass the Organization to the scanner?

Thanks!

From what I could gather - we are using SonarScanner for MSBuild 10.1.2 (.NET), SonarQube Cloud Azure Devops Extension is in use (I have tried both SonarCloudAnalyze@2 and 3).

About how the Organization is passed - I am not sure, I have checked the sonarcloud page - there is ‘Organization binding’ setup, maybe this? I have also checked the General tab there - both organization name and key does not have that + sign added.

You should be passing the organization key somehow from the CI side. For example, this could be in the Azure pipeline definition, like:

steps:
  - task: SonarCloudPrepare@1
    inputs:
      organization: your-org-key

but this is probably not your exact situation, because I think yaml is trimming strings by default.

Other common ways to pass the organization are:

  • passing command line parameters: dotnet <path to SonarScanner.MSBuild.dll> begin /k:"project-key" /o:"<organization>" but here again, I suppose you would have noticed if there is an extra space.
  • setting it in sonar-project.properties file (when using the Scanner CLI). Here it might be more possible to let a leading space slip.

You are right, we have that setup as follows:

    - task: SonarCloudPrepare@3
      displayName: 'Prepare analysis on SonarCloud'
      inputs:
        SonarCloud: ${{ parameters.sonarServiceConnection }}
        organization: ${{ parameters.organizantionName }}
        scannerMode: 'dotnet'
        projectKey: ${{ parameters.projectKey }}
        projectName: ${{ parameters.sonarProjectName }}
        extraProperties: |
         sonar.projectKey=${{ parameters.projectKey }}
         sonar.organization= ${{ parameters.organizantionName }}
         sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
         ${{ parameters.sonarExtraProperties }}

where ‘parameters.organizantionName’ is defaulted with organization name (lets say ‘xxx’, no plus sign here) value and is not modified by other yaml that is using that template.

—UPDATE - it was noticed that sonar.organization from ‘extraProperties’ was passed with extra " " here, so instead of

sonar.organization= ${{ parameters.organizantionName }}

there should be

sonar.organization=${{ parameters.organizantionName }}

Thank you for help, looks like it works now. I will keep you informed if something else happens.

1 Like

Same here, it’s still failing with the exact same setup

Hi @CDH,

Could you post the exact error you’re getting now, please?

 
Thx,
Ann

@ganncamp

Caused by: java.lang.IllegalStateException: Unable to load active rules

##[error]at org.sonar.scanner.rule.DefaultActiveRulesLoader.load(DefaultActiveRulesLoader.java:52)

at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:58)

at org.sonar.scanner.rule.ActiveRulesProvider.provide(ActiveRulesProvider.java:49)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at org.sonar.scanner.rule.DefaultActiveRulesLoader.load(DefaultActiveRulesLoader.java:52)

at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:58)

at org.sonar.scanner.rule.ActiveRulesProvider.provide(ActiveRulesProvider.java:49)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

##[error]at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)

at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)

at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)

at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)

at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)

at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)

at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)

at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)

at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)

at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)

at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)

... 50 more

Caused by: com.sonarsource.scanner.engine.webapi.client.HttpException: Error 404 on https://api.sonarcloud.io/analysis/active-rules?organization=+***-cloud-key-a42w31&project=project-name :

at com.sonarsource.scanner.engine.webapi.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:22)

at org.sonar.scanner.http.DefaultScannerWsClient.failIfUnauthorized(DefaultScannerWsClient.java:82)

at org.sonar.scanner.http.DefaultScannerWsClient.call(DefaultScannerWsClient.java:55)

at org.sonar.scanner.rule.DefaultActiveRulesLoader.load(DefaultActiveRulesLoader.java:48)

... 67 more

Hi @CDH,

Thanks for the updated error log. I’ve moved this to the thread I split off about errors from having + prepended to the org id. We’re actively working on this.

 
Thx,
Ann

Hi all,

I wanted to let you know that we have a fix in progress for this to trim parameters.

I don’t have an ETA for you yet, but it should “only” be a few hours.

Thanks for your patience.

 
Ann

1 Like

Hi again,

The fix has been deployed. Enjoy your weekend.

 
Ann

1 Like