{"record":{"id":"879790970a61d0c4","repo":"SonarSource/sonarqube","slug":"please-provide-the-personal-access-token-to-update","errorCode":null,"errorMessage":"Please provide the Personal Access Token to update the URL.","messagePattern":"Please provide the Personal Access Token to update the URL\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java","lineNumber":261,"sourceCode":"      .setWebhookSecret(setting.webhookSecret()));\n  }\n\n  public AlmSettingDto getAlmSetting(DbSession dbSession, String almSetting) {\n    return dbClient.almSettingDao().selectByKey(dbSession, almSetting)\n      .orElseThrow(() -> new NotFoundException(format(\"DevOps Platform setting with key '%s' cannot be found\", almSetting)));\n  }\n\n  public void checkPrivateKeyOnUrlUpdate(AlmSettingDto almSettingDto, String url, @Nullable String privateKey) {\n    checkCredentialArtifactOnUrlUpdate(url, almSettingDto, privateKey, \"Please provide the Private Key to update the URL.\");\n  }\n\n  public void checkPatOnUrlUpdate(AlmSettingDto almSettingDto, String url, @Nullable String pat) {\n    checkCredentialArtifactOnUrlUpdate(url, almSettingDto, pat, \"Please provide the Personal Access Token to update the URL.\");\n  }\n\n  private static void checkCredentialArtifactOnUrlUpdate(String url, AlmSettingDto almSettingDto, @Nullable String credentialArtifact, String errorMessage) {\n    if (!url.equals(almSettingDto.getUrl()) && isEmpty(credentialArtifact)) {\n      throw new IllegalArgumentException(errorMessage);\n    }\n  }\n}\n","sourceCodeStart":243,"sourceCodeEnd":265,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java#L243-L265","documentation":"IllegalArgumentException from AlmSettingsSupport.checkCredentialArtifactOnUrlUpdate (reached via checkPatOnUrlUpdate): when updating an ALM setting, the URL is being changed but no new Personal Access Token was supplied. The server requires the credential to re-validate the new endpoint, since the old PAT may not work against a different URL.","triggerScenarios":"POST api/alm_settings/update_azure (or similar) where url differs from the stored url and pat is empty/null.","commonSituations":"Rotating the server URL of an Azure DevOps organization without re-entering the PAT; automation that only patches the URL field.","solutions":["Include the current or new PAT when changing the URL","If only the PAT changes, keep the URL unchanged","Temporarily delete and re-create the setting with the new URL and PAT if the old credential is unknown"],"exampleFix":"// before\nPOST /api/alm_settings/update_azure key=azure url=https://new-url (no pat)\n// after\nPOST /api/alm_settings/update_azure key=azure url=https://new-url pat=<token>","handlingStrategy":"validation","validationCode":"const current = await ws.get('api/alm_settings/list');\nconst s = current.almSettings.find(x => x.key === key);\nif (s && url !== s.url && !pat) {\n  throw new Error('Changing the URL requires re-supplying the PAT');\n}","typeGuard":"const urlChanged = (s, newUrl) => s?.url !== newUrl;","tryCatchPattern":"try {\n  await ws.post('api/alm_settings/update_azure', {key, url, pat});\n} catch (e) {\n  if (e.status === 400 && /Please provide the Personal Access Token/.test(e.message)) {\n    const pat = await promptForPat();\n    await ws.post('api/alm_settings/update_azure', {key, url, pat});\n  } else { throw e; }\n}","preventionTips":["Always send pat (even unchanged) whenever url changes in automation","Never patch URL-only in integration updates","Store the PAT in a secret manager so rotation scripts can supply it"],"tags":["sonarqube","webapi","pat","url-update"],"backgroundTag":"missing-credentials","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"}