eclipse-csi / otterdog

OtterDog is a tool to manage GitHub organizations at scale using a configuration as code approach. It is actively used by the Eclipse Foundation to manage its numerous projects hosted on GitHub.
https://otterdog.readthedocs.org
Eclipse Public License 2.0
24 stars 4 forks source link

Duplicate key for project webhook #149

Open eclipse-csi-bot opened 11 months ago

eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Nov 30, 2023, 09:34

Project eclipse-pass added two webhooks with same url for test purpose I assume with different permission

https://github.com/eclipse-pass/pass-fcrepo-jsonld/settings/hooks

image

Github allows to create such a configuration, from otterdog cli with apply I get this exception:

Traceback (most recent call last):
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/cli.py", line 505, in _execute_operation
    exit_code = max(exit_code, operation.execute(org_config))
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/operations/diff_operation.py", line 88, in execute
    return self._generate_diff(org_config)
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/operations/diff_operation.py", line 186, in _generate_diff
    expected_org.generate_live_patch(current_org, context, handle)
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/models/github_organization.py", line 280, in generate_live_patch
    Repository.generate_live_patch_of_list(self.repositories, current_organization.repositories, context, handler)
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/models/repository.py", line 799, in generate_live_patch_of_list
    cls.generate_live_patch(expected_repo, current_repo, None, context, handler)
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/models/repository.py", line 738, in generate_live_patch
    RepositoryWebhook.generate_live_patch_of_list(
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/models/webhook.py", line 236, in generate_live_patch_of_list
    expected_webhooks_by_all_urls = multi_associate_by_key(expected_webhooks, Webhook.get_all_urls)
  File "/home/heurtemattes/workspace/workspace-otterdog/otterdog/otterdog/utils.py", line 230, in multi_associate_by_key
    raise RuntimeError(f"duplicate item found with key '{key}'")
RuntimeError: duplicate item found with key 'https://issues.library.jhu.edu/rest/bitbucket/1.0/repository/127/sync'
╷
│ Error: duplicate item found with key 'https://issues.library.jhu.edu/rest/bitbucket/1.0/repository/127/sync'
eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Nov 30, 2023, 09:36

marked this issue as blocking eclipsefdn/helpdesk#4007

eclipse-csi-bot commented 11 months ago

In GitLab by @netomi on Nov 30, 2023, 10:37

yes this is a known issue as we use the url as key. As a workaround, remove the second webhook with the same url from the config and it should work.

I dont have no idea yet how to solve that, ideally the remove the second webhook.

eclipse-csi-bot commented 11 months ago

In GitLab by @netomi on Nov 30, 2023, 10:40

I could successfully apply the changes for the eclipse-pass project, not sure goes wrong in your case? Did you do a reimport?

eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Nov 30, 2023, 12:11

Yes, I did a reimport to compare.

As discuss, I will only keep one webhook id per project.

eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Nov 30, 2023, 12:19

removed the relation with eclipsefdn/helpdesk#4007

eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Nov 30, 2023, 12:19

marked this issue as related to eclipsefdn/helpdesk#4007

eclipse-csi-bot commented 11 months ago

In GitLab by @netomi on Dec 11, 2023, 08:29

I cleaned up the webhooks for this project, still need a solution for this in general.

eclipse-csi-bot commented 11 months ago

In GitLab by @heurtemattes on Dec 11, 2023, 09:11

Thanks @netomi for taking care of this.