An action template version with this name and version already exists. To fix this problem you need to rename your template

I’ve found a weird situation in OctopusDeploy around step templates.
Scenario - We had step templates with names A and B, which has been used for a quite long time and are on a different version, Now we had to change the name of the template A to B and B to A.

Octopus is not allowing to do this, We are getting An action template version with this name and version already exists

To have a workaround we are thinking of bumping the version of the new renamed template to the number greater than the old original template in the table ActionTemplate.

We want to confirm the impact of this, As we have to manually update the table ‘ActionTemplate’ and are unsure of the database structure to be satisfied that this is enough/correct.

Hi @prateek.p,

Thanks for getting in touch! I think the best solution here would be to rename one of the templates to something else entirely before making the change.

For example, A to C, then B to A, then finally C to B. You may need to apply/update the templates usage between the changes to Octopus does not get caught up with the references.

If I am missing something here or this solution does not work, please let me know.

Looking forward to hearing from you.

Best regards,
Daniel

I think I did exactly what you are suggesting, Below are the steps I did for renaming the step template.

I had a template-A with name AWS - Create ACM Certificates - UI and template-B with name AWS - Create ACM Certificates - UI - FedRamp

We append Deprecated in the template A AWS - Create ACM Certificates - UI -DEPRECATED and then renamed template B as the same name as A which is AWS - Create ACM Certificates - UI.

All this step has been done successfully.

Now after a day when I am trying to modify the template B name - “AWS - Create ACM Certificates - UI”, It’s throwing an error saying You can’t modify an action template version with this name and version already exists to fix this problem-you-need-to-rename-your-template.

Attaching snapshots for your reference.

This is the ActionTemplateVersion table

This is the step template after we have renamed it from AWS - Create to AWS - Create ACM Certificates - UI - FedRamp to AWS - Create to AWS - Create ACM Certificates - UI. Note the version is 4.

This is showing that for our newly renamed step template there is already a version 4 (from the old step template before rename) in the ActionTemplateVersion table.

So, to me, the error is at the database level where the new name updated is clashing with the old name existing version.

Hi Daniel,
There has been no following back on this topic. I am appending my reply to this mail.

I think I did exactly what you are suggesting, Below are the steps I did for renaming the step template.

I had a template-A with name AWS - Create ACM Certificates - UI and template-B with name AWS - Create ACM Certificates - UI - FedRamp

We append Deprecated in the template A AWS - Create ACM Certificates - UI -DEPRECATED and then renamed template B as the same name as A which is AWS - Create ACM Certificates - UI.

All this step has been done successfully.

Now after a day when I am trying to modify the template B name - “AWS - Create ACM Certificates - UI”, It’s throwing an error saying You can’t modify an action template version with this name and version already exists to fix this problem-you-need-to-rename-your-template.

Attaching snapshots for your reference.

This is the ActionTemplateVersion table

image.png1397×544 530 KB

image

This is the step template after we have renamed it from AWS - Create to AWS - Create ACM Certificates - UI - FedRamp to AWS - Create to AWS - Create ACM Certificates - UI. Note the version is 4.

image.png953×441 59.5 KB

image

This is showing that for our newly renamed step template there is already a version 4 (from the old step template before rename) in the ActionTemplateVersion table.

image.png748×527 207 KB

image

So, to me, the error is at the database level where the new name updated is clashing with the old name existing version.

Hi @prateek.p,

Thanks for updating here. I am sorry for the delay in responding but I hopefully have some good news.

I had a chat to one of the developers and we devised an SQL script which should identify this versioning conflict in the ActionTemplate and resolve it by adjusting the Template version to the maximum version + 1.

This issue is actually outlined in the following GitHub issue.

As for the resolution, would you be able to first ensure that you have a fresh backup of your Octopus database before running the following script. We are confident that it should not have any adverse effects but it never hurts to be cautious.

Script to identify ActionTemplateVersion conflict and resolve:

UPDATE ActionTemplate SET [Version] = t2.MaxVersion + 1
FROM ActionTemplate t1
INNER JOIN 
(SELECT Name, MAX(Version) AS MaxVersion FROM ActionTemplateVersion
GROUP BY Name) t2
ON t1.Name = t2.Name
WHERE t1.[Version] < t2.MaxVersion

Would you be able to try this and let me know how it goes?

As a note, this script will not safeguard you against future instances of this issue, it will only act as a workaround for your templates currently experiencing this problem.

Looking forward to hearing from you.

Best regards,
Daniel

1 Like

I had this same issue and the above script worked for me with one minor change. The issue occurs when the version is Less than OR equal to the max version.

I modified the script

UPDATE ActionTemplate SET [Version] = t2.MaxVersion + 1
--select *
FROM ActionTemplate t1
INNER JOIN 
(SELECT Name, MAX(Version) AS MaxVersion FROM ActionTemplateVersion GROUP BY Name) t2
ON t1.Name = t2.Name
WHERE t1.[Version] <= t2.MaxVersion

That worked for me.

Hi @kennethgarza,

Thanks for the contribution! I’m glad to hear this helped someone else who encountered this issue.

Best regards,
Daniel