{"record":{"id":"f60ce67f19b53ac2","repo":"SonarSource/sonarqube","slug":"there-is-no-configuration-for-devops-platforms-pl","errorCode":null,"errorMessage":"There is no configuration for DevOps Platforms. Please add one.","messagePattern":"There is no configuration for DevOps Platforms\\. Please add one\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/SetPatAction.java","lineNumber":148,"sourceCode":"\n  public AlmSettingDto getAlmConfig(@Nullable String almSettingKey) {\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      if (almSettingKey != null) {\n        return getAlmSettingDtoFromKey(dbSession, almSettingKey);\n      }\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":130,"sourceCodeEnd":157,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/SetPatAction.java#L130-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running set_pat in an automation script before any integration was created; integrations deleted by another admin; wrong SonarQube environment (staging vs production).","solutions":["Create a DevOps Platform configuration (Administration > DevOps Platform Integrations) first","Pass almSetting=<key> once multiple settings exist","Point the script at the correct SonarQube instance where the setting exists"],"exampleFix":"// before\nws.post('api/alm_settings/set_pat', {pat: token})\n// after\nws.post('api/alm_settings/set_pat', {almSetting: 'azure-dev', pat: token})","handlingStrategy":"validation","validationCode":"const list = await ws.get('api/alm_settings/list');\nif (list.almSettings.length === 0) {\n  throw new Error('No DevOps Platform configuration exists; create one before set_pat');\n}","typeGuard":"const configExists = (list) => Array.isArray(list?.almSettings) && list.almSettings.length > 0;","tryCatchPattern":"try {\n  await ws.post('api/alm_settings/set_pat', {almSetting, pat});\n} catch (e) {\n  if (e.status === 404 && /no configuration for DevOps Platforms/.test(e.message)) {\n    throw new Error('Run create_azure/create_github/... first');\n  }\n  throw e;\n}","preventionTips":["Order automation: create setting, then set_pat","Verify environment (prod vs staging) before running PAT updates","Monitor for settings deletion that would break PAT rotation scripts"],"tags":["sonarqube","webapi","pat","config-missing"],"backgroundTag":"missing-configuration","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"}