{"record":{"id":"95060e20ee0e636f","repo":"SonarSource/sonarqube","slug":"email-configuration-doesn-t-exist","errorCode":null,"errorMessage":"Email configuration doesn't exist.","messagePattern":"Email configuration doesn't exist\\.","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":268,"sourceCode":"    return existingConfig.authMethod().equals(EmailConfigurationAuthMethod.OAUTH);\n  }\n\n  private static boolean isRequestParameterDefined(@Nullable NonNullUpdatedValue<?> parameter) {\n    return parameter != null && parameter.isDefined();\n  }\n\n  public void deleteConfiguration(String id) {\n    throwIfNotUniqueConfigurationId(id);\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      throwIfConfigurationDoesntExist(dbSession);\n      EMAIL_CONFIGURATION_PROPERTIES.forEach(propertyKey -> dbClient.internalPropertiesDao().delete(dbSession, propertyKey));\n      dbSession.commit();\n    }\n  }\n\n  private void throwIfConfigurationDoesntExist(DbSession dbSession) {\n    if (!configurationExists(dbSession)) {\n      throw new NotFoundException(\"Email configuration doesn't exist.\");\n    }\n  }\n\n  private boolean configurationExists(DbSession dbSession) {\n    String property = getStringInternalPropertyOrEmpty(dbSession, EMAIL_CONFIG_SMTP_HOST);\n    return StringUtils.isNotEmpty(property);\n  }\n\n  private void setInternalIfDefined(DbSession dbSession, String propertyKey, @Nullable UpdatedValue<String> value) {\n    if (value != null) {\n      value.applyIfDefined(propertyValue -> setInternalProperty(dbSession, propertyKey, propertyValue));\n    }\n  }\n\n  private void setInternalProperty(DbSession dbSession, String propertyKey, @Nullable String value) {\n    if (StringUtils.isNotEmpty(value)) {\n      dbClient.internalPropertiesDao().save(dbSession, propertyKey, value);\n    } else {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/email/config/EmailConfigurationService.java#L250-L286","documentation":"Thrown by EmailConfigurationService when the single email configuration has not been created yet: configurationExists() checks the EMAIL_CONFIG_SMTP_HOST internal property and finds it empty. getConfiguration, updateConfiguration and deleteConfiguration all call this guard and fail with NotFoundException because there is nothing to read/update/delete.","triggerScenarios":"GET/PUT/DELETE email configuration before any email SMTP settings were ever saved (no SMTP host stored in internal properties); after settings were deleted; on a fresh SonarQube install.","commonSituations":"Automation tries to update SMTP settings on a new instance without creating them first; UI/API race where a delete completed before a subsequent update; instance restored from a backup lacking internal properties.","solutions":["Call the create/POST endpoint to create the configuration before updating or reading it","Check existence first (GET and handle 404) then create-if-absent, update-if-present","Verify internal property sonar.email.* (SMTP host) exists in the DB if you believe config existed — it may have been wiped"],"exampleFix":"// before\nservice.updateConfiguration(\"default\", newCfg); // 404 if never created\n// after\ntry { service.getConfiguration(\"default\"); service.updateConfiguration(\"default\", newCfg); }\ncatch (NotFoundException e) { service.createConfiguration(newCfg); }","handlingStrategy":"try-catch","validationCode":"// create-if-missing before update\nboolean exists;\ntry { client.getEmailConfiguration(id); exists = true; }\ncatch (NotFoundException e) { exists = false; }\nif (!exists) client.createEmailConfiguration(cfg); else client.updateEmailConfiguration(id, cfg);","typeGuard":null,"tryCatchPattern":"try {\n  service.updateConfiguration(id, cfg);\n} catch (NotFoundException e) {\n  // configuration never created — create it instead\n  service.createConfiguration(cfg);\n}","preventionTips":["On fresh installs, create email config before attempting updates","Use create-or-update (upsert) wrappers around singleton config APIs","After restores/backups, verify sonar.email SMTP properties exist"],"tags":["email","smtp","not-found","configuration"],"backgroundTag":"entity-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"}