nkdAgility/azure-devops-migration-tools

Getting the following error with v15 preview 267.

MrHinsh opened this issue · 1 comments

Getting the following error with v15 preview 267.

2024-02-19 13:43:52.604 -05:00 [DBG] StringManipulatorEnricher::ProcessorExecutionWithFieldItem
2024-02-19 13:43:52.604 -05:00 [INF] [ User Story][Complete: 7/10][sid: 4|Rev: 4][tid: null | ...FAILED to Save
2024-02-19 13:43:52.604 -05:00 [INF] ===============================================================
.
.
.
2024-02-19 13:43:52.625 -05:00 [INF] ===============================================================
2024-02-19 13:43:52.625 -05:00 [ERR] System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at MigrationTools.ProcessorEnrichers.WorkItemProcessorEnrichers.StringManipulatorEnricher.ProcessorExecutionWithFieldItem(IProcessor processor, FieldItem fieldItem) in D:\a\1\s\src\MigrationTools\ProcessorEnrichers\WorkItemProcessorEnrichers\StringManipulatorEnricher.cs:line 72
at VstsSyncMigrator.Engine.WorkItemMigrationContext.PopulateWorkItem(WorkItemData oldWorkItemData, WorkItemData newWorkItemData, String destType) in D:\a\1\s\src\VstsSyncMigrator.Core\Execution\MigrationContext\WorkItemMigrationContext.cs:line 493
at VstsSyncMigrator.Engine.WorkItemMigrationContext.ReplayRevisions(List`1 revisionsToMigrate, WorkItemData sourceWorkItem, WorkItemData targetWorkItem) in D:\a\1\s\src\VstsSyncMigrator.Core\Execution\MigrationContext\WorkItemMigrationContext.cs:line 801
2024-02-19 13:43:52.626 -05:00 [INF] ===============================================================
2024-02-19 13:43:52.626 -05:00 [DBG] TfsExtensions::SaveToAzureDevOps

Seems the fieldItem.Value is a zero length string so it causes a -1 length substring error. I'm not sure what item it is inspecting though.
fieldItem.Value.ToString().Substring(0, Math.Min(fieldItem.Value.ToString().Length-1, _options.MaxStringLength-1));

Originally posted by @djbyrd in #1946

Also doing what I should have done the first time and adding some unit tests