StartIndex cannot be less than zero

Hi everyone.

Consider this my obligatory “I love Sonarr, it’s amazing, it does everything I want it to” section, because it really does.

I’ve had this installation running nearly two years now, by my reckoning. Windows 10, stable install, has run pretty much without a hitch.

This morning, I couldn’t access the web interface. Some deduction led me to the fact that the service wasn’t running, and gave me an 1053: Couldn’t start in a reasonable time error when I tried to start it manually.

Did an install over the top of the latest version. It started up. Died again. Went into the actual folder, found that I could start it by doing a run as administrator. Got it working, went in, and went to the Updates section to update to the latest development release. That seemed to download and install ok, but wouldn’t start. Went back in, ran as administrator again, big glaring error message. Basically, I’ve been hitting the same error all the way through.

“Argument Out of Range Exception: StartIndex cannot be less than zero”

I really don’t want to have to do a clean install. At last check I have roughly 1200 series in this install, and so having to re-identify them from scratch would not be ideal.

The full commandline error message from the last time I ran the Console exe as Administrator:

[Info] Bootstrap: Starting Sonarr - C:\ProgramData\NzbDrone\bin\NzbDrone.Console.exe - Version 2.0.0.4641
[Debug] ProcessProvider: Found 1 processes with the name: NzbDrone.Console
[Debug] ProcessProvider:  - [10696] NzbDrone.Console
[Debug] ProcessProvider: Found 0 processes with the name: NzbDrone
[Info] MigrationLogger: *** Migrating data source=C:\ProgramData\NzbDrone\nzbdrone.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
[Info] MigrationLogger: *** 108: fix_extra_file_extension migrating ***
[Debug] MigrationLogger: Beginning Transaction
[Info] fix_extra_file_extension: Starting migration to 108
[Debug] MigrationLogger: PerformDBOperation
[Debug] MigrationLogger: Performing DB Operation
[Error] MigrationLogger: System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
   at System.String.Substring(Int32 startIndex, Int32 length)
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtensionForTable(IDbConnection conn, IDbTransaction tran, String table) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 35
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtension(IDbConnection conn, IDbTransaction tran) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 18
   at FluentMigrator.Runner.Processors.SQLite.SQLiteProcessor.Process(PerformDBOperationExpression expression) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\Processors\SQLite\SQLiteProcessor.cs:line 113
   at FluentMigrator.Builders.Execute.PerformDBOperationExpression.ExecuteWith(IMigrationProcessor processor) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator\Builders\Execute\ExecuteExpressionRoot.cs:line 67
   at FluentMigrator.Runner.MigrationRunner.<>c__DisplayClass72_0.<ExecuteExpressions>b__1() in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 489
   at FluentMigrator.Runner.StopWatch.Time(Action action) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\StopWatch.cs:line 57
   at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 489

[v2.0.0.4641] System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
   at System.String.Substring(Int32 startIndex, Int32 length)
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtensionForTable(IDbConnection conn, IDbTransaction tran, String table) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 35
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtension(IDbConnection conn, IDbTransaction tran) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 18
   at FluentMigrator.Runner.Processors.SQLite.SQLiteProcessor.Process(PerformDBOperationExpression expression) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\Processors\SQLite\SQLiteProcessor.cs:line 113
   at FluentMigrator.Builders.Execute.PerformDBOperationExpression.ExecuteWith(IMigrationProcessor processor) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator\Builders\Execute\ExecuteExpressionRoot.cs:line 67
   at FluentMigrator.Runner.MigrationRunner.<>c__DisplayClass72_0.<ExecuteExpressions>b__1() in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 489
   at FluentMigrator.Runner.StopWatch.Time(Action action) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\StopWatch.cs:line 57
   at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 489

[Debug] MigrationLogger: Rolling back transaction


[Fatal] ConsoleApp: EPIC FAIL!

[v2.0.0.4641] System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
   at System.String.Substring(Int32 startIndex, Int32 length)
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtensionForTable(IDbConnection conn, IDbTransaction tran, String table) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 35
   at NzbDrone.Core.Datastore.Migration.fix_extra_file_extension.FixExtraFileExtension(IDbConnection conn, IDbTransaction tran) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\108_fix_extra_file_extension.cs:line 18
   at FluentMigrator.Runner.Processors.SQLite.SQLiteProcessor.Process(PerformDBOperationExpression expression) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\Processors\SQLite\SQLiteProcessor.cs:line 113
   at FluentMigrator.Builders.Execute.PerformDBOperationExpression.ExecuteWith(IMigrationProcessor processor) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator\Builders\Execute\ExecuteExpressionRoot.cs:line 67
   at FluentMigrator.Runner.MigrationRunner.<>c__DisplayClass72_0.<ExecuteExpressions>b__1() in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 489
   at FluentMigrator.Runner.StopWatch.Time(Action action) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\StopWatch.cs:line 57
   at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 502
   at FluentMigrator.Runner.MigrationRunner.ExecuteMigration(IMigration migration, Action`2 getExpressions) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 458
   at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(IMigrationInfo migrationInfo, Boolean useTransaction) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 308
   at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement) in C:\Users\Mark\Source\Repos\fluentmigrator\src\FluentMigrator.Runner\MigrationRunner.cs:line 157
   at NzbDrone.Core.Datastore.Migration.Framework.MigrationController.Migrate(String connectionString, MigrationContext migrationContext) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\Migration\Framework\MigrationController.cs:line 51
   at NzbDrone.Core.Datastore.DbFactory.Create(MigrationContext migrationContext) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\DbFactory.cs:line 84
   at NzbDrone.Core.Datastore.DbFactory.Create(MigrationType migrationType) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\DbFactory.cs:line 56
   at NzbDrone.Core.Datastore.DbFactory.RegisterDatabase(IContainer container) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Datastore\DbFactory.cs:line 36
   at NzbDrone.Host.Bootstrap.Start(ApplicationModes applicationModes, StartupContext startupContext) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Host\Bootstrap.cs:line 73
   at NzbDrone.Host.Bootstrap.Start(StartupContext startupContext, IUserAlert userAlert, Action`1 startCallback) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Host\Bootstrap.cs:line 40
   at NzbDrone.Console.ConsoleApp.Main(String[] args) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Console\ConsoleApp.cs:line 20

Thought it would be worth mentioning that I too have the same problem since this morning.

An issue in a recent update then, perhaps?

I have the same problem too.

Seems like it. I’m wondering what’s the best way to handle this issue until the problem is resolved. Download an old build, install that and then copy over the backup files from the latest update? And then just turn off auto update until the problem is fixed? Is there something I’m overlooking, I would like to get this running again shortly.

Got the same error today

Can someone PM me a copy of their database? I’d like to verify how Sonarr is running into this as it shouldn’t be happening and it’s not something I’m seeing locally.

I just installed a fresh copy from the installer on the website. Then copied over my old backup, things were running fine. Shortly after starting Sonarr the updater ran again and caused the same error. I will try to get you a link with my DB file later but it’s quite large at 250MB.

1 Like

Will try once I’m home. Can you confirm the likely name of the file you need?

I have PM’ed markus my database…

Good thing it is lunch time and Chrome Remote Desktop is installed on all my servers :smiley:

Thanks @prsinister!

The underlying issue is extensionless files in the series folder that are stored in Sonarr’s DB. I’ve done two thing to correct this:

  • Prevent extensionless files from being imported as extra files
  • Delete the extensionless files from Sonarr’s DB so fix the migration

To get Sonarr back up and running you’ll can grab 2.0.0.4642+ (now available) manually and install that.

If you’re curious which file in your library are extensionless you can run: SELECT * FROM ExtraFiles WHERE TRIM(Extension) = '' on the nzbdrone.db file in a SQLite editor and clean them up on disk manually.

Awesome stuff. The latest release I see on github is v2.0.0.4613. Am I looking in the wrong place or what is the best place to find 2.0.0.4642+?

You’ll want the develop release which you can grab here: http://download.sonarr.tv/v2/develop/latest/

Fantastic! Seems to be up and working with the new develop release.

I ran the SQL query, and found the 5 files that were screwing it up - remnants of a dead HDD that I recovered files from. I’ve deleted them off the disk now, so hopefully there shouldn’t be any further issues. Thanks again!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.