{"record":{"id":"72862975dd47031d","repo":"SonarSource/sonarqube","slug":"parameter-s-is-required-as-there-are-multiple-dev-728629","errorCode":null,"errorMessage":"Parameter %s is required as there are multiple DevOps Platform configurations.","messagePattern":"Parameter (.+?) is required as there are multiple DevOps Platform configurations\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/SetPatAction.java","lineNumber":153,"sourceCode":"      }\n      return getAlmSettingDtoFromAlm(dbSession);\n    }\n  }\n\n  private AlmSettingDto getAlmSettingDtoFromKey(DbSession dbSession, String almSettingKey) {\n    return dbClient.almSettingDao().selectByKey(dbSession, almSettingKey)\n      .orElseThrow(() -> new NotFoundException(String.format(\"DevOps Platform configuration '%s' not found.\", almSettingKey)));\n  }\n\n  private AlmSettingDto getAlmSettingDtoFromAlm(DbSession dbSession) {\n    List<AlmSettingDto> almSettingDtos = dbClient.almSettingDao().selectAll(dbSession);\n    if (almSettingDtos.isEmpty()) {\n      throw new NotFoundException(\"There is no configuration for DevOps Platforms. Please add one.\");\n    }\n    if (almSettingDtos.size() == 1) {\n      return almSettingDtos.get(0);\n    }\n    throw new IllegalArgumentException(String.format(\"Parameter %s is required as there are multiple DevOps Platform configurations.\", PARAM_ALM_SETTING));\n  }\n\n}\n","sourceCodeStart":135,"sourceCodeEnd":157,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/SetPatAction.java#L135-L157","documentation":"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.","triggerScenarios":"POST /api/alm_settings/set_pat without almSetting while selectAll returns 2+ rows.","commonSituations":"Legacy scripts from the single-integration era run against instances that now have multiple Azure/GitHub/GitLab configurations.","solutions":["Supply almSetting with the target configuration key","Update automation scripts to always pass almSetting","Delete redundant configurations if duplicates are accidental"],"exampleFix":"// before\nclient.post('/api/alm_settings/set_pat', {pat: pat})\n// after\nclient.post('/api/alm_settings/set_pat', {almSetting: 'bitbucket-server', pat: pat})","handlingStrategy":"validation","validationCode":"const list = await ws.get('api/alm_settings/list');\nif (list.almSettings.length > 1) {\n  params.almSetting = params.almSetting ?? list.almSettings[0].key; // or resolve explicitly\n}","typeGuard":"const needsExplicitKey = (n) => n > 1;","tryCatchPattern":"try {\n  await ws.post('api/alm_settings/set_pat', params);\n} catch (e) {\n  if (e.status === 400 && /Parameter .* is required/.test(e.message)) {\n    throw new Error('Pass almSetting key: ' + (await ws.get('api/alm_settings/list')).almSettings.map(s=>s.key));\n  }\n  throw e;\n}","preventionTips":["Make almSetting a mandatory argument in internal tooling","Migrate single-config scripts when enabling the multiple-ALM feature","Document setting keys in team runbooks"],"tags":["sonarqube","webapi","pat","ambiguous-config"],"backgroundTag":"missing-required-argument","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}