{"record":{"id":"562bd56c192a921d","repo":"SonarSource/sonarqube","slug":"it-is-not-possible-to-synchronize-sonarqube-using-562bd5","errorCode":null,"errorMessage":"It is not possible to synchronize SonarQube using GitLab, as it is already managed by .","messagePattern":"It is not possible to synchronize SonarQube using GitLab, as it is already managed by \\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java","lineNumber":320,"sourceCode":"  }\n\n  private void triggerRun(GitlabConfiguration gitlabConfiguration) {\n    throwIfConfigIncompleteOrInstanceAlreadyManaged(gitlabConfiguration);\n    managedInstanceService.queueSynchronisationTask(userSession.getUuid());\n  }\n\n  private void throwIfConfigIncompleteOrInstanceAlreadyManaged(GitlabConfiguration configuration) {\n    checkInstanceNotManagedByAnotherProvider();\n    checkState(AUTO_PROVISIONING.equals(configuration.provisioningType()), \"Auto provisioning must be activated\");\n    checkState(configuration.enabled(), getErrorMessage(\"GitLab authentication must be turned on\"));\n    checkState(isNotBlank(configuration.provisioningToken()), getErrorMessage(\"Provisioning token must be set\"));\n  }\n\n  private void checkInstanceNotManagedByAnotherProvider() {\n    if (managedInstanceService.isInstanceExternallyManaged()) {\n      Optional.of(managedInstanceService.getProviderName()).filter(providerName -> !\"gitlab\".equals(providerName))\n        .ifPresent(providerName -> {\n          throw new IllegalStateException(\"It is not possible to synchronize SonarQube using GitLab, as it is already managed by \"\n            + providerName + \".\");\n        });\n    }\n  }\n\n  private static String getErrorMessage(String prefix) {\n    return format(\"%s to enable GitLab provisioning.\", prefix);\n  }\n\n  public Optional<String> validate(GitlabConfiguration gitlabConfiguration) {\n    if (!gitlabConfiguration.enabled()) {\n      return Optional.empty();\n    }\n    String url = (gitlabConfiguration.url() + \"/api/v4\").replace(\"//\", \"/\");\n    try {\n      gitlabGlobalSettingsValidator.validate(\n        toValidationMode(gitlabConfiguration.provisioningType()),\n        url,","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java#L302-L338","documentation":"SonarQube allows only one identity provider to manage instance-level provisioning at a time. checkInstanceNotManagedByAnotherProvider throws this IllegalStateException from the GitLab config flow when ManagedInstanceService reports the instance is already externally managed by a provider other than 'gitlab'.","triggerScenarios":"Creating or updating a GitLab configuration (via throwIfConfigIncompleteOrInstanceAlreadyManaged) while the instance is managed by a different provider, e.g. GitHub or Azure DevOps; note that providerName==\"gitlab\" is allowed through.","commonSituations":"Migrating between identity providers without first unmanaging the instance; enabling GitHub integration and GitLab sync simultaneously; stale managed-instance state after removing a previous integration.","solutions":["Disable/unmanage the current identity provider integration (e.g. GitHub or Azure DevOps provisioning) before configuring GitLab synchronization.","Verify which provider manages the instance via the managed instance settings/API.","If the other integration was already removed, ensure the managed-instance flag was cleared in the database."],"exampleFix":"// before\nPOST /api/gitlab/configure (instance managed by GitHub)\n\n// after\nDELETE /api/github/configuration (unmanage instance first)\nPOST /api/gitlab/configure","handlingStrategy":"try-catch","validationCode":"// check before configuring GitLab sync\nif (managedInstanceService.isInstanceExternallyManaged() && !\"gitlab\".equals(managedInstanceService.getProviderName())) {\n  throw new IllegalStateException(\"Instance managed by another provider\");\n}","typeGuard":null,"tryCatchPattern":"try { service.createConfiguration(params); } catch (IllegalStateException e) { log.error(\"Resolve existing provider first: {}\", e.getMessage()); }","preventionTips":["Unmanage or disable other identity-provider integrations (GitHub, Azure DevOps) before setting up GitLab sync.","Audit managed-instance state during provider migrations."],"tags":["gitlab","identity-provider","state-conflict","provisioning"],"backgroundTag":"invalid-state-transition","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"}