SonarSource/sonarqube · error · NotFoundException

Gitlab configuration with id

Error message

Gitlab configuration with id %s not found

What it means

GitlabConfigurationService supports a single GitLab configuration keyed by UNIQUE_GITLAB_CONFIGURATION_ID. throwIfNotUniqueConfigurationId throws NotFoundException for any other id passed to getConfiguration or deleteConfiguration. Any caller-provided id other than the reserved one cannot match, hence 'not found'.

Solutions

  1. List/read the existing GitLab configuration to obtain its real id and use exactly that
  2. Use the documented singleton configuration id for reads and deletes
  3. Treat NotFoundException as 'wrong id' and fall back to listing configs rather than retrying the same id

Example fix

// before
deleteConfiguration("gitlab-prod")
// after
var cfg = getConfiguration(UNIQUE_GITLAB_CONFIGURATION_ID);
deleteConfiguration(cfg.getId());
Defensive patterns

Strategy: validation

Validate before calling

var existing = client.getGitlabConfiguration();
if (existing.isEmpty()) throw new IllegalStateException("GitLab configuration not yet created");
String id = existing.get().getId(); // the only valid id

Type guard

boolean isKnownGitlabConfigId(String id, Set<String> knownIds) {
  return id != null && knownIds.contains(id);
}

Try / catch

try {
  service.deleteConfiguration(id);
} catch (NotFoundException e) {
  log.warn("'{}' is not the singleton GitLab configuration id", id);
}

Prevention

When it happens

Trigger: GET/DELETE GitLab configuration endpoints with arbitrary ids (e.g. 'gitlab-prod', a UUID) instead of the fixed supported id; stale clients or payloads reused from other integrations.

Common situations: Automation templating configuration ids; docs/tutorials referencing multi-config products; typos or case differences in the reserved id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/0655493f53a5a6bf. Report an issue: GitHub.

Appendix: source

Thrown at server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java:190

  private Boolean getBooleanOrFalse(DbSession dbSession, String property) {
    return Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(dbSession, property))
      .map(dto -> Boolean.valueOf(dto.getValue())).orElse(false);
  }

  private String getStringPropertyOrEmpty(DbSession dbSession, String property) {
    return Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(dbSession, property))
      .map(PropertyDto::getValue).orElse("");
  }

  private String getStringPropertyOrNull(DbSession dbSession, String property) {
    return Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(dbSession, property))
      .map(dto -> Strings.emptyToNull(dto.getValue())).orElse(null);
  }

  private static void throwIfNotUniqueConfigurationId(String id) {
    if (!UNIQUE_GITLAB_CONFIGURATION_ID.equals(id)) {
      throw new NotFoundException(format("Gitlab configuration with id %s not found", id));
    }
  }

  public void deleteConfiguration(String id) {
    throwIfNotUniqueConfigurationId(id);
    try (DbSession dbSession = dbClient.openSession(false)) {
      throwIfConfigurationDoesntExist(dbSession);
      GITLAB_CONFIGURATION_PROPERTIES.forEach(property -> dbClient.propertiesDao().deleteGlobalProperty(property, dbSession));
      dbClient.externalGroupDao().deleteByExternalIdentityProvider(dbSession, GitLabIdentityProvider.KEY);
      dbSession.commit();
    }
  }

  private void throwIfConfigurationDoesntExist(DbSession dbSession) {
    checkFound(dbClient.propertiesDao().selectGlobalProperty(dbSession, GITLAB_AUTH_ENABLED), "GitLab configuration doesn't exist.");
  }

  private static ProvisioningType toProvisioningType(boolean provisioningEnabled) {

View on GitHub (pinned to 184c821202)