Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Cannot export project: Version ## of ... (ActionTemplates-#) step template could not be found. Reference path: Project ... => Deployment Process => Deployment Action

Open akirayamamoto opened this issue 2 years ago • 1 comments

Team

  • [X] I've assigned a team label to this issue

Severity

Multiple customers affected

Version

Present in 2022.1

Latest Version

No response

What happened?

Somehow the customer database get into an inconsistent state. When they try to export a project there is a reference to an action template version that does not exist.

Reproduction

N/A at the moment.

Error and Stacktrace

Version ## of the '...' (ActionTemplates-##) step template could not be found. Reference path: Project '...' => Deployment Process => Deployment Action '...'

More Information

Original thread

The SQL script below could be used to find missing action template references:

SELECT
	s.[Name] AS SpaceName
	,p.[Name] AS ProjectName
	,r.[Version] AS ReleaseVersion
	,Step.ActionTemplateId
	,Step.ActionTemplateVersion
FROM [dbo].[Release] r
JOIN [dbo].[DeploymentProcess] dp
	ON dp.Id = r.ProjectDeploymentProcessSnapshotId
JOIN [dbo].[Project] p
	ON p.Id = dp.OwnerId
JOIN [dbo].[Space] s
	ON s.Id = p.SpaceId
CROSS APPLY OPENJSON(dp.[JSON]) WITH (
	Steps nvarchar(max) '$.Steps' AS JSON
) dpJson
CROSS APPLY OPENJSON(dpJson.Steps) WITH (
	Actions nvarchar(max) '$.Actions' AS JSON
) stepsJson
CROSS APPLY OPENJSON(stepsJson.Actions) WITH (
	ActionTemplateId nvarchar(50) '$.Properties."Octopus.Action.Template.Id"'
	,ActionTemplateVersion nvarchar(50) '$.Properties."Octopus.Action.Template.Version"'
) Step
WHERE
	Step.ActionTemplateId IS NOT NULL
	AND (
		-- template does not exist
		NOT EXISTS (SELECT 1 FROM [dbo].[ActionTemplate] act WHERE act.Id = Step.ActionTemplateId)
		OR (
			Step.ActionTemplateVersion IS NOT NULL
​
			-- template version does not match latest
			AND NOT EXISTS (SELECT 1 FROM [dbo].[ActionTemplate] act WHERE act.Id = Step.ActionTemplateId AND act.[Version] = Step.ActionTemplateVersion)
​
			-- template version is not on version table
			AND NOT EXISTS (SELECT 1 FROM [dbo].[ActionTemplateVersion] actv WHERE actv.LatestActionTemplateId = Step.ActionTemplateId AND actv.[Version] = Step.ActionTemplateVersion)
		)
	)

Workaround

Manually remove or update the reference to the missing action template version and export again.

akirayamamoto avatar Nov 02 '22 22:11 akirayamamoto

We have been unable to replicate this issue so are looking for input from customers to help us diagnose this. If you have experienced this error please either fill out this form or book in a time to chat to our product team.

michelle-luana avatar Nov 20 '22 23:11 michelle-luana