SonarQube Publish Quality Gate Result error 400: API GET '/api/ce/task' failed, status code was: 400

After producing build warnings as expected, I’m finding that My SonarQube Publish Quality Gate Result step gets to an error 400 and I appear to have hit a bit of a dead end in getting it set up.

Logs show:

##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 200 Body: "{"task":{"id":"AXsb0WQ3LC6AkZHS05UY","type":"REPORT","componentId":"AXsbe3pELC6AkZHS05UN","componentKey":"my-project-key","componentName":"my-component-namel","componentQualifier":"TRK","status":"IN_PROGRESS","submittedAt":"2021-08-06T15:15:12+0100","submitterLogin":"admin","startedAt":"2021-08-06T15:15:13+0100","executionTimeMs":24228,"logs":false,"organization":"default-organization"}}"
##[debug][SQ] Task status:IN_PROGRESS
##[debug][SQ] Waiting for task 'AXsb0WQ3LC6AkZHS05UY' to complete.
##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 200 Body: "{"task":{"id":"AXsb0WQ3LC6AkZHS05UY","type":"REPORT","componentId":"AXsbe3pELC6AkZHS05UN","componentKey":"my-project-key","componentName":"my-component-namel","componentQualifier":"TRK","status":"IN_PROGRESS","submittedAt":"2021-08-06T15:15:12+0100","submitterLogin":"admin","startedAt":"2021-08-06T15:15:13+0100","executionTimeMs":25343,"logs":false,"organization":"default-organization"}}"
##[debug][SQ] Task status:IN_PROGRESS
##[debug][SQ] Waiting for task 'AXsb0WQ3LC6AkZHS05UY' to complete.
##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 400 Body: "{"errors":[{"msg":"Value of parameter 'additionalFields' (warnings) must be one of: [stacktrace, scannerContext]"}]}"
##[debug][SQ] API GET '/api/ce/task' failed, status code was: 400
##[error][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]task result: Failed
##[error][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]Processed: ##vso[task.complete result=Failed;][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
Finishing: SonarQubePublish

Oddly, the logs show the same API GET: ‘/api/ce/task’ requests running with the same arguments and receiving a 200 response before getting to:

##[debug][SQ] API GET '/api/ce/task' failed, status code was: 400
##[error][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]task result: Failed
##[error][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'

I’ve found examples of 404 and 401 errors for this same GET request but no mentions of a 400 response.

Azure DevOps configuration looks like:

- task: SonarQubePrepare@4
  inputs:
    SonarQube: 'SonarQube Connection'
    scannerMode: 'MSBuild'
    projectKey: 'my-project-key'
    projectName: 'my-project-name'
    extraProperties: |
      # Additional properties that will be passed to the scanner, 
      # Put one key=value per line, example:
      # sonar.exclusions=**/*.bin
      sonar.verbose=true

# Build the entire solution so the test assemblies are available
- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: MySolution.sln
    platform: 'Any CPU'
    configuration: 'Release'

- task: SonarQubeAnalyze@4
- task: SonarQubePublish@4
  inputs:
    pollingTimeoutSec: '300'

I’m running Devops from the cloud (if that matters) with the current plugin (as opposed to deprecated) and SonarQube v 6.7. What am I doing wrong?

Hi,

Welcome to the community!

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

6.7 → 7.9.6 → 8.9.2 → 9.0.1 (last step optional)

Regarding your actual question, a lot has changed since 6.7, including possibly the web services involved in these calls. (Sorry, but it really has been a while.) Once you’ve upgraded, if the error persists, please do come back to us.

 
:woman_shrugging:
Ann

Hi, Ann,

Thanks. I’ll try that. I didn’t realise how out of date we were!

Regards,

Bob

1 Like

Hi Ann,

I hope this message finds you well. I’ve been encountering the same issue over the past few days. I’m using SonarCloud in an Azure DevOps pipeline for PR analysis of a TypeScript project. However, in the SonarCloudPublish@1 step, I’m facing a failure with the following error:

##[error][SQ] API GET ‘/api/ce/task’ failed, status code was: 404
##[error][SQ] Could not fetch task for ID ‘AY3pk2SqC6LpY66u24U_’

Interestingly, when I use Postman to hit the same API endpoint, I can see the results. Could you please assist in resolving this issue?

Thanks

Hi @Sourav_Padhi,

This topic is nearly 2.5 years old. Per the FAQ, please create a new one with all your details.

 
Ann