tcWebHooks: Webhooks not showing when project is copied

Expected Behavior

When copying a project, the new project should show the webhooks correctly.

Current Behavior

The webhooks will only show in one of the projects (it’s not deterministic which one)

Steps to Reproduce (for bugs)

  1. Create a project (Project1)
  2. Setup a webhook on the project
  3. Copy the project (to Project2)
  4. view the webhooks for each project, webhooks will only be visible on one project

Problem

We copy projects on a semi-regular basis, to support our old “LTS” branches.

The new webhook has the same id as the old webhook, meaning that when it ends up in this map, we drop webhook instances.

This is similar to https://github.com/tcplugins/tcWebHooks/issues/10 - we’d need to deal with modifying the IDs during copy, but it still doesn’t look like there’s a nice way of being notified when a copy happens.

I looked to see what would happen if we dropped the uniqueid altogether, and it seems about half of the usages are around logging, but there’s still a lot of spots that require some thinking.

🤔 An option could be to prefix the unique id with the project id when dealing with it in code, so the duplicate id’s in the config dont matter.

🤔 Another option could be to drop the id from the config, and generate a hash of the projectid+the entire webhook config for use as the id?

Workaround

We can modify the id’s manually in the config so they are unique, but it’s not ideal.

Your Environment

  • tcWebHooks Version: 1.2.5
  • TeamCity Version: 2023.11
  • TeamCity server Operating System: Linux
  • Are you using a WebHook Template?: no

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (27 by maintainers)

Most upvoted comments

I presume it still exists or you wouldn’t have mentioned it. I’ll look at it for this release. Is there any more detail I should know about how to reproduce it. If so please raise a new issue

Just reconfirmed it - I listed out the repro steps in https://github.com/tcplugins/tcWebHooks/issues/242 to make it as easy to track down as I could.

I suspect the fix could be related to this one - capturing an event when the build config is deleted and modifying the webhook there.

I wonder if that might cause things to take longer than 10 seconds?

Pavel tells me that projectRestored will fire when the VCS config is reloaded. I’ve added support for that event too in this PR

the persisted file on disk still refers to the original id.

Yeah, that’s the last piece to fix.

How do you copy the projects? On the file system or via the UI (or REST API) or some other way?

We do it via the admin UI

image