Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 26, 2025

The FieldClearMap was causing a runtime error when users tried to use it in their field mapping configuration:

System.InvalidOperationException: No service for type 'MigrationTools.FieldMaps.AzureDevops.ObjectModel.FieldClearMap' has been registered.
          at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
          at MigrationTools.Tools.FieldMappingTool..ctor(IOptions`1 options, IServiceProvider services, ILogger`1 logger, ITelemetryLogger telemetry)

This occurred when users configured the field map in their migration settings:

{
  "FieldMapType": "FieldClearMap",
  "ApplyTo": ["Feature"],
  "targetField": "System.Description"
}

The issue was that while the FieldClearMap class was fully implemented and documented, it was missing from the dependency injection service registration in the AddMigrationToolServicesForClientLegacyAzureDevOpsObjectModel method.

Root Cause

The FieldMappingTool resolves field maps from the DI container using Services.GetRequiredService(type), but FieldClearMap was not registered as a transient service like other field maps.

Changes

  • Added context.AddTransient<FieldClearMap>(); to the service registration in ServiceCollectionExtensions.cs
  • Added test coverage for FieldClearMapOptions configuration
  • Added service registration test to verify DI container resolution

Impact

Users can now successfully use the FieldClearMap functionality that was already documented and implemented but previously inaccessible due to the missing service registration.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]:</issue_title>
<issue_description>### Version

  • I confirm that I am using the latest version

Source Version

Azure DevOps Service

Target Version

Azure DevOps Service

Relevant configuration

{
            "FieldMapType": "FieldClearMap",
            "ApplyTo": [
              "Feature"
            ],
            "targetField": "System.Description"
          }

Relevant log output

Unhandled exception!
System.InvalidOperationException: No service for type 'MigrationTools.FieldMaps.AzureDevops.ObjectModel.FieldClearMap' has been registered.
          at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
          at MigrationTools.Tools.FieldMappingTool..ctor(IOptions`1 options, IServiceProvider services, ILogger`1 logger, ITelemetryLogger telemetry) in D:\a\1\s\src\MigrationTools\Tools\FieldMappingTool.cs:line 48

What happened?

I am trying to use the FieldClearMap to clear the Description field for migrated work items. I get the error 'No service for type 'MigrationTools.FieldMaps.AzureDevops.ObjectModel.FieldClearMap' has been registered.' and then the migrator quits without migrating the work item.

Debug in Visual Studio

  • Visual Studio Debug</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #3002

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] [Bug]: Fix FieldClearMap service registration issue causing runtime error Sep 26, 2025
Copilot finished work on behalf of MrHinsh September 26, 2025 15:10
@Copilot Copilot AI requested a review from MrHinsh September 26, 2025 15:10
@nkdagility-actions-bot
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://blue-river-093197403-3005.westeurope.5.azurestaticapps.net

1 similar comment
@nkdagility-actions-bot
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://blue-river-093197403-3005.westeurope.5.azurestaticapps.net

@MrHinsh MrHinsh marked this pull request as ready for review September 29, 2025 14:20
@MrHinsh MrHinsh merged commit ffa829e into main Sep 29, 2025
26 of 35 checks passed
@MrHinsh MrHinsh deleted the copilot/fix-77910aef-d042-48fd-9ba2-5d8592a83c4b branch September 29, 2025 14:21
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

Successfully merging this pull request may close these issues.

[Bug]:

2 participants