Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk migration tool - System.ArgumentOutOfRangeException when exporting failed customers #93

Closed
ahueyshi opened this issue Jun 3, 2022 · 1 comment

Comments

@ahueyshi
Copy link

ahueyshi commented Jun 3, 2022

Steps to reproduce

In bulk migration tool, select "2. Export subscriptions with migration eligibility".
Issue occurs after "Exporting failed customers" starts.

Expected behavior

Failed customer list is exported to CSV.

Actual behavior

Program crashes with "Unhandled exception. System.ArgumentOutOfRangeException".

Diagnostic logs

Unhandled exception. System.ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'length')
   at System.String.Substring(Int32 startIndex, Int32 length)
   at NCEBulkMigrationTool.CsvProvider.ExportCsv[T](IEnumerable`1 data, String fileName) in C:\...\nce-bulk-migration-tool\NCEBulkMigrationTool\CsvProvider.cs:line 24
   at NCEBulkMigrationTool.SubscriptionProvider.ExportLegacySubscriptionsAsync() in C:\...\nce-bulk-migration-tool\NCEBulkMigrationTool\SubscriptionProvider.cs:line 79
   at Program.<<Main>$>g__RunAsync|0_1(IServiceProvider serviceProvider) in C:\...\nce-bulk-migration-tool\NCEBulkMigrationTool\Program.cs:line 85
   at Program.<Main>$(String[] args) in C:\...\nce-bulk-migration-tool\NCEBulkMigrationTool\Program.cs:line 54
   at Program.<Main>(String[] args)

Note the failing code in ExportCsv:

    int index = fileName.LastIndexOf('/');
    var directory = fileName[..index];  // fails here
    Directory.CreateDirectory(directory);

And the calling line from SubscriptionProvider.cs:

    if (failedCustomersBag.Count > 0)
    {
        Console.WriteLine("Exporting failed customers");
        await csvProvider.ExportCsv(failedCustomersBag, "failedCustomers.csv"); // calling line
        Console.WriteLine($"Exported failed customers at {Environment.CurrentDirectory}/failedCustomers.csv");
    }

The method is clearly being called with a filename only, so the attempt to locate the training slash returns a -1, causing the substring call to fail. The call should contain a folder path.

Environment

Using the latest posted code for the bulk migration tool.

@ahueyshi
Copy link
Author

Looks like this was fixed in commit 36bf534.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant