{"record":{"id":"6598c586b4177907","repo":"SonarSource/sonarqube","slug":"email-configuration-with-id-s-not-found","errorCode":null,"errorMessage":"Email configuration with id %s not found","messagePattern":"Email configuration with id (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-common/src/main/java/org/sonar/server/common/email/config/EmailConfigurationService.java","lineNumber":165,"sourceCode":"      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_PORT),\n      EmailConfigurationSecurityProtocol.valueOf(getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_SECURE_CONNECTION)),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_FROM),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_FROM_NAME),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_PREFIX),\n      EmailConfigurationAuthMethod.valueOf(getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_AUTH_METHOD)),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_USERNAME),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_PASSWORD),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_HOST),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_CLIENTID),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_CLIENTSECRET),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_TENANT),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_SCOPE),\n      getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_OAUTH_GRANT));\n  }\n\n  private static void throwIfNotUniqueConfigurationId(String id) {\n    if (!UNIQUE_EMAIL_CONFIGURATION_ID.equals(id)) {\n      throw new NotFoundException(format(\"Email configuration with id %s not found\", id));\n    }\n  }\n\n  private String getStringInternalPropertyOrEmpty(DbSession dbSession, String property) {\n    return dbClient.internalPropertiesDao().selectByKey(dbSession, property).orElse(\"\");\n  }\n\n  public Optional<EmailConfiguration> findConfigurations() {\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      if (configurationExists(dbSession)) {\n        return Optional.of(getConfiguration(UNIQUE_EMAIL_CONFIGURATION_ID, dbSession));\n      }\n      return Optional.empty();\n    }\n  }\n\n  public EmailConfiguration updateConfiguration(UpdateEmailConfigurationRequest updateRequest) {\n    try (DbSession dbSession = dbClient.openSession(true)) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/email/config/EmailConfigurationService.java#L147-L183","documentation":"EmailConfigurationService supports exactly one email configuration, stored under a fixed internal property key UNIQUE_EMAIL_CONFIGURATION_ID. throwIfNotUniqueConfigurationId throws NotFoundException for any id other than that fixed value. Since the ID is fixed by the platform, any caller-supplied id that differs is reported as 'not found'.","triggerScenarios":"GET/DELETE email configuration endpoints with an arbitrary id (e.g. copied from an old doc, a UUID, or 'default') instead of the single supported id; stale client code that cached a different id.","commonSituations":"API consumers assume multiple email configs exist and pass their own ids; integrations migrated from other products that allowed multiple SMTP configurations; typo in the reserved id.","solutions":["Call the list/get endpoint without an id first to discover the actual supported configuration id and use exactly that","Delete with the same id returned by getConfiguration","If migrating, recreate settings under the supported id rather than reusing legacy ids"],"exampleFix":"// before\ndeleteConfiguration(\"my-smtp-1\")\n// after\nEmailConfiguration cfg = getConfiguration(UNIQUE_EMAIL_CONFIGURATION_ID);\ndeleteConfiguration(cfg.getId()); // the single supported id","handlingStrategy":"validation","validationCode":"// discover the supported id before read/delete\nList<EmailConfiguration> configs = client.getEmailConfigurations();\nif (configs.isEmpty()) throw new IllegalStateException(\"no email configuration exists\");\nString id = configs.get(0).getId(); // use this id, never a custom one","typeGuard":"boolean isKnownEmailConfigId(String id, Set<String> knownIds) {\n  return id != null && knownIds.contains(id);\n}","tryCatchPattern":"try {\n  service.deleteConfiguration(id);\n} catch (NotFoundException e) {\n  log.warn(\"Email configuration id '{}' not found; listing valid ids\", id);\n  // fall back to listing and re-resolving the id\n}","preventionTips":["Never invent email configuration ids — always read them from the get/list endpoint","Remember the product supports a single email configuration","Write 404 handling for id-based config APIs (email, github, gitlab) uniformly"],"tags":["email","smtp","not-found","configuration"],"backgroundTag":"resource-not-found","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}