Piwik Pro API Copying Tags does not work if copying multiple tags in fast succession (Bug)

I am trying to copy 15 tags from a “source” app to a “destination” app via the Tag Manager API (Tags — Piwik PRO Analytics Suite 18.27 documentation )

While the copying works if I wait 10 seconds between each copying operation, it does not if I copy one tag after another quickly. Only a few, sometimes 1, sometimes 2-4 tags actually end up in the destination app.

And this happens even though I get a 202 status response (SUCCESS) after calling the copy method. The respons is WITH an ID for the tag in the destination app, so it looks as if the tag WAS created (otherwise there would be no ID).
But if I then run a query to get the tag list of the destination app, the copied tag is NOT in the list.

I am running the copy operations synchronously, so the next copying operation does NOT start UNLESS the previous copying operation has received the “202 SUCCESS” status.

This seems like a severe bug in the Tag Manager API.
The API returns “202 SUCCESS” before the copying operation inside of Piwik TM has fully completed, so when the next copying operation starts, it probably overwrites the previous operation.

The API must not return “202 SUCCESS” status if the copying process is not fully complete yet and the copied tag cannot be used yet.

I have added some polling to the logic and it seems like 1-2 seconds are always enough. But this is still sth that needs to be fixed. The API cannot return “202 Success” if the success is not really complete yet.

Piwik Support: “I’ve confirmed it with our devs, and it turns out that’s expected behaviour.”

So it is expected behaviour to tell the user that something is completed when it is not, and it has severe repercussions when the user makes any action based on the assumption that this has completed… Really don’t know what to say here… :sweat_smile:

And cherry on top: I didn’t reply to this answer for about an hour, and the ticket was “closed due to client inactivity”…

Hey Lukas,
I’m glad the support thread reached a conclusion. We will be updating our documentation to clarify exactly how the endpoint works.

In the meantime, here’s a quick summary for anyone who might run into a similar situation:

  • Calling this endpoint does not result in immediate success; instead, it schedules an operation. You can check the status of this job through a separate endpoint.
  • When a copy request is made, an operation ID is provided. This can be tracked at the following endpoint: Operations endpoint.
  • A 202 response code indicates that the task has been accepted to begin the copy operation, but it does not confirm that the operation has been successfully completed.

Thanks for bringing this up, and I apologize for the inactivity notification.
Thank you!
Piotr

1 Like