Octopus.Migrator.exe NullReferenceException

I’m running an export of my Octopus configs through the command line so that I can version control the settings. I was previously running Octopus.3.0.7.2204-x64 and it was working fine. Once I updated to Octopus.3.0.12.2366-x64 I started getting a NullReferenceException during the export. It fails on trying to export the first “variable-set-snapshot.json”.

This is the command I’m running in a custom step:
&"$OctopusMigratorPath\Octopus.Migrator.exe" “export” “–console” “–instance” “"$OctopusServiceInstance”" “–directory” “"$WorkingFolder”" “–password” “"$MasterKey”"

Here is the log entry:
2015-08-12 14:30:00.0368 1 FATAL System.NullReferenceException: Object reference not set to an instance of an object.
at Octopus.Migrator.ExportProcess.ExportController.WriteVariableSetSnapshotForRelease(ExportContext context, IRelationalTransaction transaction, Release release, String directoryPath) in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 167
at Octopus.Migrator.ExportProcess.ExportController.WriteReleases(ExportContext context) in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 143
at Octopus.Migrator.ExportProcess.ExportController.Export() in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 93
at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in Y:\work\refs\heads\master\source\Octopus.Shared\Startup\AbstractCommand.cs:line 57
at Octopus.Shared.Startup.ConsoleHost.Run(Action1 start, Action shutdown) in Y:\work\refs\heads\master\source\Octopus.Shared\Startup\ConsoleHost.cs:line 34 2015-08-12 14:30:00.0680 1 FATAL Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Octopus.Migrator.ExportProcess.ExportController.WriteVariableSetSnapshotForRelease(ExportContext context, IRelationalTransaction transaction, Release release, String directoryPath) in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 167 at Octopus.Migrator.ExportProcess.ExportController.WriteReleases(ExportContext context) in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 143 at Octopus.Migrator.ExportProcess.ExportController.Export() in Y:\work\refs\heads\master\source\Octopus.Migrator\ExportProcess\ExportController.cs:line 93 at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in Y:\work\refs\heads\master\source\Octopus.Shared\Startup\AbstractCommand.cs:line 57 at Octopus.Shared.Startup.ConsoleHost.Run(Action1 start, Action shutdown) in Y:\work\refs\heads\master\source\Octopus.Shared\Startup\ConsoleHost.cs:line 81
at Octopus.Shared.Startup.OctopusProgram.Run() in Y:\work\refs\heads\master\source\Octopus.Shared\Startup\OctopusProgram.cs:line 73

Hi Karim,

Sorry you are having a problem with this.

The capability to export LibraryVariableSet snapshots was added recently which explains why this has just started. But as to why it’s happening … I’d like to investigate with you further.

Could you please go into SQL Management Studio and take a look at the Releases table using a command like:
SELECT TOP 100 * FROM [OctopusDeploy].[dbo].[Release] ORDER By [Assembled] DESC

Take a look at the JSON column. Where you see “LibraryVariableSetSnapshots” you should either see an empty array after it [] or something like "LibraryVariableSetSnapshots":[{"LibraryVariableSetId":"LibraryVariableSets-1","VariableSetSnapshotId":"variableset-LibraryVariableSets-1-s-1-T7RRV"}]

Do you see any that are not properly formed like this?

If you could share a copy of the Releases table with us (support@octopusdeploy.com) we could also take a look directly. (Right-click Save-As from SQL Management Studio).

Ian Mercer

I’ve sent a full dump of the table to the support team.