Thank you for contacting Octopus Support and welcome to the forums!
I am sorry you are seeing this error when deploying a release, it does look like you may be running into this known bug -
Does this look like what you are experiencing?
If so there are a few workarounds in that GitHub issue to rectify this but you will need to delete that deployment unfortunately, my latest comment on that issue is the best way to fix this via the API and not the Database:
Alternatively, delete the deployment via the API:
Find all the deployments for the broken release
Delete any deployments which have a TaskId of null
Let me know if that GitHub issue is not related to this though and we can take another look for you, the issue itself was fixed in 2022.3.2568 but you will still experience it if you upgrade, as you would need to delete that deployment.
Also of note in that issue if it is related:
To avoid releases ending up in this state:
Switch to a manual deployment phase lifecycle
Check project tenanted deployment mode settings - if you only need tenanted deployments, don’t select both untenanted and tenanted
Hopefully that helps but let us know if the issue is unrelated and we can take another look,