SonarSource/sonarqube · error · ForbiddenException

You're not authorized to push analysis results to the SonarQ

Error message

You're not authorized to push analysis results to the SonarQube server. Please contact your SonarQube administrator.

What it means

ProjectDataLoader.checkPermission verifies the submitting user holds the 'scan/provisioning' permission before accepting uploaded analysis data. Without it the loader refuses to import the report and throws ForbiddenException with this user-facing message. It prevents unauthorized pushes of analysis results to the server.

Source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java:88

  }

  private List<FilePathWithHashDto> searchFilesWithHashAndRevision(DbSession session, @Nullable ComponentDto branchComponent) {
    if (branchComponent == null) {
      return Collections.emptyList();
    }
    return dbClient.componentDao().selectEnabledFilesFromProject(session, branchComponent.uuid());
  }

  private static void addFileData(ProjectRepositories data, List<FilePathWithHashDto> files) {
    for (FilePathWithHashDto file : files) {
      FileData fileData = new FileData(file.getSrcHash(), file.getRevision());
      data.addFileData(file.getPath(), fileData);
    }
  }

  private static void checkPermission(boolean hasScanPerm) {
    if (!hasScanPerm) {
      throw new ForbiddenException("You're not authorized to push analysis results to the SonarQube server. " +
        "Please contact your SonarQube administrator.");
    }
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Grant the 'Execute Analysis' permission to the CI user/group on the project (Project Settings > Permissions)
  2. Regenerate the scanner token from an account that has Execute Analysis
  3. If permissions come from a DevOps platform, sync/group membership there and re-authenticate
  4. Check global 'Execute Analysis' permission if the project is not yet provisioned

Example fix

// before: scanner token of plain user
SONAR_TOKEN=user-low-priv-token
// after: token of account with Execute Analysis on the project
SONAR_TOKEN=ci-service-account-token
Defensive patterns

Strategy: validation

Validate before calling

// before pushing, verify permission:
GET api/permissions/search?project=<key>&permission=scan — confirm the token's user appears

Try / catch

try { loader.load(...); } catch (ForbiddenException e) { failBuild("Grant Execute Analysis to the CI account"); }

Prevention

When it happens

Trigger: A scanner or CI job authenticates with a token whose user lacks the Execute Analysis (scan) permission on the project, and posts to api/batch/project (internal batch endpoints).

Common situations: SonarQube upgrade from versions where scan permission was granted to Anyone; token created for a user who lost project permissions; CI service account not added to the project with Execute Analysis; externally managed instance revoking local permissions.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/ab27f54028da9263. Report an issue: GitHub.