{"record":{"id":"c436079e22cd09e3","repo":"SonarSource/sonarqube","slug":"it-is-not-possible-to-synchronize-sonarqube-using","errorCode":null,"errorMessage":"It is not possible to synchronize SonarQube using GitHub, as it is already managed by .","messagePattern":"It is not possible to synchronize SonarQube using GitHub, 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/github/config/GithubConfigurationService.java","lineNumber":360,"sourceCode":"      .orElse(Set.of());\n  }\n\n  private void triggerRun(GithubConfiguration githubConfiguration) {\n    throwIfConfigIncompleteOrInstanceAlreadyManaged(githubConfiguration);\n    managedInstanceService.queueSynchronisationTask(userSession.getUuid());\n  }\n\n  private void throwIfConfigIncompleteOrInstanceAlreadyManaged(GithubConfiguration configuration) {\n    checkInstanceNotManagedByAnotherProvider();\n    checkState(AUTO_PROVISIONING.equals(configuration.provisioningType()), \"Auto provisioning must be activated\");\n    checkState(configuration.enabled(), getErrorMessage(\"GitHub authentication must be turned on\"));\n  }\n\n  private void checkInstanceNotManagedByAnotherProvider() {\n    if (managedInstanceService.isInstanceExternallyManaged()) {\n      Optional.of(managedInstanceService.getProviderName()).filter(providerName -> !GitHubIdentityProvider.KEY.equals(providerName))\n        .ifPresent(providerName -> {\n          throw new IllegalStateException(\"It is not possible to synchronize SonarQube using GitHub, as it is already managed by \" + providerName + \".\");\n        });\n    }\n  }\n\n  private static String getErrorMessage(String prefix) {\n    return format(\"%s to enable GitHub provisioning.\", prefix);\n  }\n\n  public Optional<String> validate(GithubConfiguration configuration) {\n    if (!configuration.enabled()) {\n      return Optional.empty();\n    }\n    try {\n      githubGlobalSettingsValidator.validate(configuration.applicationId(), configuration.clientId(), configuration.clientSecret(), configuration.privateKey(),\n        configuration.apiUrl());\n    } catch (Exception e) {\n      return Optional.of(e.getMessage());\n    }","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/github/config/GithubConfigurationService.java#L342-L378","documentation":"When validating a GitHub provisioning configuration, checkInstanceNotManagedByAnotherProvider consults ManagedInstanceService: if the instance is already externally managed (identity/provisioning delegated to another provider, e.g. Azure AD, GitLab, SAML-based managed sync), enabling GitHub synchronization is refused with this IllegalStateException. The provider name is interpolated into the message (hence the trailing dot placement).","triggerScenarios":"Saving/updating GitHub configuration (createConfiguration with incomplete/managed checks via throwIfConfigIncompleteOrInstanceAlreadyManaged) while isInstanceExternallyManaged() is true and the managing provider's key is not 'github'.","commonSituations":"Instance already provisioned by GitLab or Azure DevOps autosync; admin migrates identity providers without disabling the previous managed-instance integration; SSO/SCIM provider configured org-wide.","solutions":["Disable/detach the current external management provider (Administration > the existing provisioning integration) before enabling GitHub provisioning","Or keep GitHub as the manager: if the provider shown is GitHub itself, this check is skipped, so re-verify which provider is active","Check managed instance status via admin APIs/UI to confirm the active provider","Plan one provider for provisioning — remove the conflicting integration first, then save the GitHub config"],"exampleFix":"// before\nenable github provisioning while gitlab autosync active\n// after\ndisable GitLab provisioning (delete GitLab configuration / turn off autosync), then createConfiguration(githubConfig)","handlingStrategy":"validation","validationCode":"// before enabling GitHub provisioning\nif (managedInstanceService.isInstanceExternallyManaged()\n    && !\"github\".equals(managedInstanceService.getProviderName())) {\n  throw new IllegalStateException(\"disable current provider: \" + managedInstanceService.getProviderName());\n}","typeGuard":null,"tryCatchPattern":"try {\n  service.createConfiguration(cfg);\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"already managed by\")) {\n    // disable the other provider, then retry once\n    disableCurrentManagedInstanceProvider();\n    service.createConfiguration(cfg);\n  } else throw e;\n}","preventionTips":["Keep exactly one provisioning/identity provider active at a time","Check the managed-instance status in Administration before enabling a new one","Script provider migrations as disable-old then enable-new, never both"],"tags":["github","provisioning","configuration-conflict","sso"],"backgroundTag":"conflicting-config-options","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"}