SonarSource/sonarqube · error · NotFoundException

There is no configuration for DevOps Platforms. Please add o

Error message

There is no configuration for DevOps Platforms. Please add one.

What it means

NotFoundException thrown by SetPatAction.getAlmSettingDtoFromAlm when updating a Personal Access Token via api/alm_settings/set_pat but no DevOps Platform configuration exists at all. The action cannot find an ALM setting to attach the PAT to.

Source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/SetPatAction.java:148

  public AlmSettingDto getAlmConfig(@Nullable String almSettingKey) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      if (almSettingKey != null) {
        return getAlmSettingDtoFromKey(dbSession, almSettingKey);
      }
      return getAlmSettingDtoFromAlm(dbSession);
    }
  }

  private AlmSettingDto getAlmSettingDtoFromKey(DbSession dbSession, String almSettingKey) {
    return dbClient.almSettingDao().selectByKey(dbSession, almSettingKey)
      .orElseThrow(() -> new NotFoundException(String.format("DevOps Platform configuration '%s' not found.", almSettingKey)));
  }

  private AlmSettingDto getAlmSettingDtoFromAlm(DbSession dbSession) {
    List<AlmSettingDto> almSettingDtos = dbClient.almSettingDao().selectAll(dbSession);
    if (almSettingDtos.isEmpty()) {
      throw new NotFoundException("There is no configuration for DevOps Platforms. Please add one.");
    }
    if (almSettingDtos.size() == 1) {
      return almSettingDtos.get(0);
    }
    throw new IllegalArgumentException(String.format("Parameter %s is required as there are multiple DevOps Platform configurations.", PARAM_ALM_SETTING));
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Create a DevOps Platform configuration (Administration > DevOps Platform Integrations) first
  2. Pass almSetting=<key> once multiple settings exist
  3. Point the script at the correct SonarQube instance where the setting exists

Example fix

// before
ws.post('api/alm_settings/set_pat', {pat: token})
// after
ws.post('api/alm_settings/set_pat', {almSetting: 'azure-dev', pat: token})
Defensive patterns

Strategy: validation

Validate before calling

const list = await ws.get('api/alm_settings/list');
if (list.almSettings.length === 0) {
  throw new Error('No DevOps Platform configuration exists; create one before set_pat');
}

Type guard

const configExists = (list) => Array.isArray(list?.almSettings) && list.almSettings.length > 0;

Try / catch

try {
  await ws.post('api/alm_settings/set_pat', {almSetting, pat});
} catch (e) {
  if (e.status === 404 && /no configuration for DevOps Platforms/.test(e.message)) {
    throw new Error('Run create_azure/create_github/... first');
  }
  throw e;
}

Prevention

When it happens

Trigger: POST /api/alm_settings/set_pat without almSetting parameter when selectAll(ALM_SETTINGS) returns an empty list — i.e., zero DevOps Platform integrations are configured.

Common situations: Running set_pat in an automation script before any integration was created; integrations deleted by another admin; wrong SonarQube environment (staging vs production).

Related errors


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