The given key was not present in the dictionary

(Cale Banfield) #1

Hello,

The problem I am having is that we are currently migrating our projects from one server to another to move development in-house.
When I go to import the .json file using octo.exe, I get the exception:

“Handshake successful. Octopus version: 3.3.24; API version: 3.0.0
Authenticated as: pdsadmin <>
Finding importer 'project’
Validating the import
Export file successfully loaded
Checking that lifecycle PDS - CCMS - Lifecycle exists
Lifecycle PDS - CCMS - Lifecycle does not exist, default lifecycle will be used instead
Found lifecycle 'Default Lifecycle’
Checking that all environments exist
Checking that all machines exist
Checking that all NuGet Feeds exist
Checking that all Action Templates exist
Checking that all Library Variable Sets exist
Checking that the Project Group exist
Chekcing that all channel lifecycles exist
No validation errors found. Project is ready to import.
Beginning the import
Beginning import of project 'PDS.CcMS’
Importing Project
Project does not exist, a new project will be created
Importing the channels for the project
Channel already exists, channel will be updated with new settings
Importing the Projects Deployment Process
Updating ID of NuGet Feed
Updating IDs of Environments
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Octopus.Cli.Importers.ProjectImporter.ImportDeploymentProcess(DeploymentProcessResource deploymentProcess, ProjectResource importedProject, IDictionary2 environments, IDictionary2 nugetFeeds, IDictionary2 actionTemplates, IDictionary2 channels) at Octopus.Cli.Importers.ProjectImporter.Import(Dictionary2 paramDictionary)
at Octopus.Cli.Importers.BaseImporter.Import(String[] parameters)
at Octopus.Cli.Commands.ImportCommand.Execute()
at Octopus.Cli.Commands.ApiCommand.Execute(String[] commandLineArguments)
at Octopus.Cli.Program.Main(String[] args)
Exit code: -3”

I have edited the .json file and so all the variables reference the correct environment and machine. I thought this would solve the problem but apparently not. I should also point out that the server that the project was exported from was using v3.3.0 whereas the server we’re trying to import to is using v3.3.24. I can’t find any documentation on what could be causing this error, so any help would be greatly appreciated.

Regards,

Cale Banfield

2019.3.3 LTS - The given key was not present in the dictionary
(Rob Pearson) #2

Hi Cale,

Thanks for getting in touch. I think it’s failing at the following line of code (octo.exe is open source so it’s full source is available on GitHub). https://github.com/OctopusDeploy/Octo.exe/blob/master/source/Octopus.Cli/Importers/ProjectImporter.cs#L412

It’s failing to find an environment ID associated with one of the deployment process steps (actions). I would suggest double-checking the environment IDs to ensure the ones listed in the JSON file match the target server. In this case, it shouldn’t matter that the two servers are different versions.

That said, I’d like to mention that we have a better solution for import/export coming in Octopus 3.4. We’ve enhanced our migrator to add support to import/export individual projects and it’s far more robust than the current solution in octo.exe. This is coming soon so I’d recommend keeping it in mind when you’re ready to upgrade to the latest version.

Let me know how you go.

Rob

(Cale Banfield) #3

Hi Rob,

You are correct. One of the actions referenced an environment that no longer exists. I feel pretty silly for missing that haha.

Thanks again for your time.

Regards,

Cale Banfield

(Rob Pearson) #4

Hi Cale,

No worries. It’s great to hear you got it working.

Happy deploying!

Rob

(Octopus Support) #5

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.

(system) closed #7