I’ve found a weird situation in OctopusDeploy around step templates. Normally, after I create a step template using the API I can edit it, either with the API directly again or through the web UI. However, somewhere between 3.12.0 (works) and 3.12.4 (does not), I’m seeing an issue. I’ve tried it on 3.12.5 (does not work) and 3.12.6 (does not work) as well. If the step template contains a “Parameter”, any later attempts to update it returns the strangely-worded error
"ErrorMessage": "There was a problem with your request.",
"An action template verision with this name and version already exists."
I’m able to replicate this error with the following step template declaration:
After POSTing that json blob to $OCTOPUS_URL/api/actiontemplates , the resulting step template can no longer be edited, for example by adding features to it or adding text in any textbox. Any idea what might be causing that error?
Thanks for getting in touch. I wasn’t able to reproduce the issue but I think I’ve figured out what is happening. That error message is shown when there is a duplicate step template name and version in a database history table (Octopus maintains a history of step template changes/details). I’m guessing there is some wierd combination of things happening that is causing this issue.
Can you run the following queries against your Octopus database and share the results?
SELECT Id, Name, Version, LatestActionTemplateId, ActionType FROM ActionTemplateVersion;
SELECT Id, Name, Version, ActionType, CommunityActionTemplateId FROM ActionTemplate;
NOTE: You can make this conversation private if there is anything you’d like to keep private.
I suspect there is a duplicate step template name/version in the history table (ActionTemplateVersion) and it’s causing problems. If we can confirm this, we can likely isolate/fix the bug or cleanup your database.
Very cool, Rob. On additional investigation based on what you put in your response, I figured out that the first upload of the template is fine, but if you delete that template, then add a new one with the same name, it is the replacement that cannot be edited.
In the meantime, I’ll get with my DBA to pull the queries you wanted.
Just a quick follow-up, one of my team members found a bug based on your reply and created a GitHub issue to get it fixed. Can you take a look at it and let me know if this is the same issue you’re seeing or if your scenario is different.
That issue is exactly what we’re seeing. Turns out if I manually prune the orphaned ActionTemplateVersion rows (solution 1 of the github issue there) then my cannot-edit-step-templates problem is solved. This is a perfectly serviceable workaround until that issue is resolved.