SonarSource/sonarqube · error · IllegalArgumentException

Parameter %s is required as there are multiple DevOps Platfo

Error message

Parameter %s is required as there are multiple DevOps Platform configurations.

What it means

IllegalArgumentException thrown by SetPatAction when several DevOps Platform configurations exist and set_pat was called without an almSetting parameter, making it impossible to know which configuration the PAT belongs to.

Source

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

      }
      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. Supply almSetting with the target configuration key
  2. Update automation scripts to always pass almSetting
  3. Delete redundant configurations if duplicates are accidental

Example fix

// before
client.post('/api/alm_settings/set_pat', {pat: pat})
// after
client.post('/api/alm_settings/set_pat', {almSetting: 'bitbucket-server', pat: pat})
Defensive patterns

Strategy: validation

Validate before calling

const list = await ws.get('api/alm_settings/list');
if (list.almSettings.length > 1) {
  params.almSetting = params.almSetting ?? list.almSettings[0].key; // or resolve explicitly
}

Type guard

const needsExplicitKey = (n) => n > 1;

Try / catch

try {
  await ws.post('api/alm_settings/set_pat', params);
} catch (e) {
  if (e.status === 400 && /Parameter .* is required/.test(e.message)) {
    throw new Error('Pass almSetting key: ' + (await ws.get('api/alm_settings/list')).almSettings.map(s=>s.key));
  }
  throw e;
}

Prevention

When it happens

Trigger: POST /api/alm_settings/set_pat without almSetting while selectAll returns 2+ rows.

Common situations: Legacy scripts from the single-integration era run against instances that now have multiple Azure/GitHub/GitLab configurations.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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