Error when importing data between 2 octopus instances

Hi

We have 3 new projects on a dev octopus instance (running version 3.11.1) which I want to import from, into our production octopus instance (running octopus 3.8.2).
I performed an export on the dev server and then copied the relevant folders/files to the prod server and i try performing an import.
2 of the projects are OK (preview goes well when i have only them in the import folder, but the 3rd (one i have all 3 in the import folder) causes the import to break with the following error:

ERROR An unexpected error occurred when processing document with source ID ‘deploymentprocess-Projects-103’: Padding is invalid and cannot be removed.
System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
at System.Security.Cryptography.CapiSymmetricAlgorithm.DepadBlock(Byte[] block, Int32 offset, Int32 count)
at System.Security.Cryptography.CapiSymmetricAlgorithm.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
at System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at Octopus.Core.Security.MasterKey.MasterKeyEncryption.ToPlaintext(Byte[] masterKey, EncryptedBytes encrypted) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Core\Security\MasterKey\MasterKeyEncryption.cs:line 84
at Octopus.Core.Security.MasterKey.MasterKeyEncryptionExtensions.ToPlaintextString(IMasterKeyEncryption encryption, EncryptedBytes encrypted) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Core\Security\MasterKey\MasterKeyEncryptionExtensions.cs:line 21
at Octopus.Core.RelationalStorage.PropertyValueConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Core\RelationalStorage\PropertyValueConverter.cs:line 58
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
at Octopus.Migrator.DocumentImporters.DeploymentProcessImporter.Convert(ImportedDocument source, ImportContext context, String id, DeploymentProcess existing) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Migrator\DocumentImporters\DeploymentProcessImporter.cs:line 32
at Octopus.Migrator.DocumentImporters.ConventionBasedImporter2.InsertNewDocument(ImportedDocument document, ImportContext context, Identity identity) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Migrator\DocumentImporters\ConventionBasedImporter.cs:line 156 at Octopus.Migrator.DocumentImporters.ConventionBasedImporter2.Import(ImportedDocument document, ImportContext context) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Migrator\DocumentImporters\ConventionBasedImporter.cs:line 115
at Octopus.Migrator.ImportProcess.ImportController.ConvertDocuments(ImportContext context) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 497
2017-03-06 17:35:27.7932 1 INFO The document content was:
{
…json content which i will ommit…
}

2017-03-06 17:35:27.9651 1 ERROR ===============================================================================
2017-03-06 17:35:28.0120 1 FATAL Padding is invalid and cannot be removed.
System.Security.Cryptography.CryptographicException
at System.Security.Cryptography.CapiSymmetricAlgorithm.DepadBlock(Byte[] block, Int32 offset, Int32 count)
at System.Security.Cryptography.CapiSymmetricAlgorithm.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
at System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at Octopus.Core.Security.MasterKey.MasterKeyEncryption.ToPlaintext(Byte[] masterKey, EncryptedBytes encrypted) in MasterKeyEncryption.cs:line 84
at Octopus.Core.Security.MasterKey.MasterKeyEncryptionExtensions.ToPlaintextString(IMasterKeyEncryption encryption, EncryptedBytes encrypted) in MasterKeyEncryptionExtensions.cs:line 21
at Octopus.Core.RelationalStorage.PropertyValueConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in PropertyValueConverter.cs:line 58
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
at Octopus.Migrator.DocumentImporters.DeploymentProcessImporter.Convert(ImportedDocument source, ImportContext context, String id, DeploymentProcess existing) in DeploymentProcessImporter.cs:line 32
at Octopus.Migrator.DocumentImporters.ConventionBasedImporter2.InsertNewDocument(ImportedDocument document, ImportContext context, Identity identity) in ConventionBasedImporter.cs:line 156 at Octopus.Migrator.DocumentImporters.ConventionBasedImporter2.Import(ImportedDocument document, ImportContext context) in ConventionBasedImporter.cs:line 115
at Octopus.Migrator.ImportProcess.ImportController.ConvertDocuments(ImportContext context) in ImportController.cs:line 488
at Octopus.Migrator.ImportProcess.ImportController.ExecuteWithTimer(ImportContext ctx, String name, Action1 work) in ImportController.cs:line 160 at Octopus.Migrator.ImportProcess.ImportController.ImportDocuments(IImportedDocumentSource backup) in ImportController.cs:line 102 at Octopus.Migrator.ImportProcess.ImportController.Import(IImportedDocumentSource backup) in ImportController.cs:line 80 at Octopus.Migrator.Commands.ImportFilesCommand.Start() in ImportFilesCommand.cs:line 97 at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions, String displayName, String version, String informationalVersion, String[] environmentInformation, String instanceName) in AbstractCommand.cs:line 78 at Octopus.Shared.Startup.OctopusProgram.Start(ICommandRuntime commandRuntime) in OctopusProgram.cs:line 214 at Octopus.Shared.Startup.ConsoleHost.Run(Action1 start, Action shutdown) in ConsoleHost.cs:line 77
at Octopus.Shared.Startup.OctopusProgram.Run() in OctopusProgram.cs:line 104

2017-03-06 17:35:28.0432 1 ERROR ===============================================================================
2017-03-06 17:35:28.1214 1 ERROR The master key does not match the encryption used in the database
2017-03-06 17:35:28.1370 1 ERROR -------------------------------------------------------------------------------
2017-03-06 17:35:28.1682 1 ERROR A new install creates a new master key. If you then restore data from another instance with a different master key you will get this exception. This error can also occur if you try to upgrade a 2.5 instance to 3.0 without first upgrading to 2.6.
2017-03-06 17:35:28.1995 1 ERROR See: http://g.octopushq.com/SecurityAndEncryption

I’ve found the following discussions in the forum, but they didn’t help me in resolving the problem:

  1. http://help.octopusdeploy.com/discussions/problems/35187-padding-is-invalid-and-cannot-be-removed-error-in-30-preview
  2. http://community.octopusdeploy.com/t/error-in-import/428

I used to be able to import projects in the past (older versions) between these 2 instances and having the sensitive variables empty instead of failing the import - is this something which was changed?
Is there a way to workaround or solve the problem?

Thanks
Nir

Hi,
I think I might have narrowed the issue down slightly, I’ve noticed that the project which is failing to get imported is doing so because on one of the steps which deploys an IIS website the identity option which is being used is the builtin “Application Pool Identity” which I think is causing import to fail.
Is it right to say that projecs that are using this option can’t be imported between 2 instances?
Thanks
Nir

Hi Nir,

Thanks for getting in touch! The IIS WebSite settings shouldn’t cause the migration to fail - under the covers all of those settings are just loosely typed string dictionaries. If I am wrong, it is a bug and we will fix it. :slight_smile:

The more likely problem(s) are:

  1. We don’t support, and generally don’t test migrating data between two Octopus Servers of different versions.
  2. The Padding is invalid and cannot be removed error whilst migrating is generally due to entering the wrong password either during export, or during import.

I would recommend aligning the source/target Octopus Server versions, and double-checking the password. If the problem still persists please don’t hesitate to get back in touch, and attach the entire migrator log file. If you do attach the migrator log, please mark this thread as private.

Hope that helps!
Mike

Hi Michael,
Thank you so much for the VERY prompt response, especially during off-hours - much appreciated.
I’ll upgrade the second server tomorrow as well as re-export/import to make sure the password is correct.
I will update with the results as soon as I am done.
Thanks and good night,
Nir

Get Outlook for iOShttps://aka.ms/o0ukef


update:
I’ve upgraded the target server to the same version (3.11.1) and then tried running the export which failed prior to upgrading - this wasn’t successful
then created a new export and imported that one.
this one succeeded.
Joy!

Thanks,
Nir

Hi Nir,

Thanks for keeping in touch! So it sounds like it was the password for the export/import?

Thanks!
Mike

Hi Michael

I am not sure exactly, because if it had been the password I would think that all 3 projects would fail and not only 1 of them…
I suspect that it’s either that (but I am pretty sure I had the right password), or maybe something else was corrupted in that initial export.

Kind regards,
Nir

Hi Nir,

No worries! I’m glad to hear it’s working out for you again.

Happy Deployments!
Mike