GitHub sync fails after updating GitHub teams in the org

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) SonarQube enterprise 10.5.1
  • how is SonarQube deployed: Docker
  • what are you trying to achieve: I used to have a GitHub App that configured manual triggering of synchronization with my GitHub teams. I have a use case that requires me to be able to recreate these teams, so the team ids will change. I think this means that, in the external_groups table, external_group_id will change. When I try to synchronize after one such recreation, I cannot complete the sync due to index uniqueness constraint. Is SonarQube using a basic insert for this command, and does it make sense to allow upserting to this table?
  • To recreate the issue:
    • I had a team in GitHub call team-a
    • I renamed that team to team-a-old
    • I created a new team-a
    • I triggered the SonarQube sync
    • I ran into the Unique Key constraint violation in SonarQube
  • Due to this fail, I am also unable to onboard new people to use SonarQube.

The error message is here:
Error querying database. Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.user.ExternalGroupMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Batch entry 0 insert into external_groups ( group_uuid, external_group_id, external_identity_provider ) values ( 'some_uuid', 'id', 'github' ) was aborted: ERROR: duplicate key value violates unique constraint "pk_external_groups" Detail: Key (group_uuid)=(some_uuid) already exists. Call getNextException to see other errors in the batch. ### The error may exist in org.sonar.db.user.ExternalGroupMapper ### The error may involve org.sonar.db.user.ExternalGroupMapper.selectByExternalIdAndIdentityProvider ### The error occurred while executing a query ### Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.user.ExternalGroupMapper.insert (batch index #1) failed. Cause: jav

Hi Murat,

First of all, I apologies for coming back to you so late.
I thank you for raising this bug and being very clear on how to reproduce the issue. I confirm this needs to be fixed. I have created a ticket (here) to address the issue and I already started to work on it. The fix should be available in the next version.

In the meantime, there is a workaround to fix your issue, try to do it in 2 steps:

  • First, rename your team-a to team-a-old and synchronise (either manually or wait for the next automatic synchronisation)
  • Then, create the new team-a and synchronise (either manually or wait for the next automatic synchronisation)

Regards,
Nolwenn

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.