nkdAgility/azure-devops-migration-tools

[Bug]: Pipeline Processor returning "UnsupportedMediaTypeException"

raquelgarciag opened this issue · 11 comments

Version

  • I confirm that I am using the latest version

Source Version

Azure DevOps Server 2019

Target Version

Azure DevOps Service

Relevant configuration

{
  "Version": "0.0",
  "LogLevel": "Debug",
  "TelemetryEnableTrace": false,
  "workaroundForQuerySOAPBugEnabled": false,
  "Source": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "mycollectionurlhere",
    "Project": "myprojhere",
    "ReflectedWorkItemIDFieldName": "Custom.ReflectedWorkItemId",
    "AuthenticationMode": "Prompt",
    "AllowCrossProjectLinking": false,
    "PersonalAccessToken": "myPAThere",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "Target": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "url",
    "Project": "proj",
    "ReflectedWorkItemIDFieldName": "Custom.ReflectedWorkItemId",
    "AuthenticationMode": "AccessToken",
    "AllowCrossProjectLinking": false,
    "PersonalAccessToken": "pat",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "FieldMaps": [

    {
      "$type": "FieldSkipMapConfig",
      "WorkItemTypeName": "User Story",
      "targetField": "Custom.Raquel"
    }

  ],
  "WorkItemTypeDefinition": {
    "User Story": "User Story"
  },
  "GitRepoMapping": null,
  "CommonEnrichersConfig": [
    {
      "$type": "TfsNodeStructureOptions",
      "PrefixProjectToNodes": false,
      "NodeBasePaths": [],
      "AreaMaps": {},
      "IterationMaps": {},
      "ShouldCreateMissingRevisionPaths": true
    }
  ],
  "Processors": [
    {
      "$type": "AzureDevOpsPipelineProcessorOptions",
      "Enabled": true,
      "MigrateBuildPipelines": true,
      "MigrateReleasePipelines": true,
      "MigrateTaskGroups": false,
      "MigrateVariableGroups": false,
      "MigrateServiceConnections": false,
      "BuildPipelines": null,
      "ReleasePipelines": null,
      "RefName": null,
      "SourceName": "Source",
      "TargetName": "Target",
      "RepositoryNameMaps": {},
      "versionParameter": "5.1"
    },
    {
      "$type": "TeamMigrationConfig",
      "Enabled": false,
      "PrefixProjectToNodes": false,
      "EnableTeamSettingsMigration": true,
      "FixTeamSettingsForExistingTeams": false
    },
    {
      "$type": "WorkItemMigrationConfig",
      "Enabled": false,
      "ReplayRevisions": true,
      "PrefixProjectToNodes": false,
      "UpdateCreatedDate": true,
      "UpdateCreatedBy": true,
      "WIQLQueryBit": "AND [System.Tags] CONTAINS 'crc'",
      "WIQLOrderBit": "[System.ChangedDate] desc",
      "LinkMigration": true,
      "AttachmentMigration": true,
      "AttachmentWorkingPath": "c:\\temp\\WorkItemAttachmentWorkingFolder\\",
      "FixHtmlAttachmentLinks": false,
      "SkipToFinalRevisedWorkItemType": true,
      "WorkItemCreateRetryLimit": 5,
      "FilterWorkItemsThatAlreadyExistInTarget": true,
      "PauseAfterEachWorkItem": false,
      "AttachmentMaxSize": 480000000,
      "AttachRevisionHistory": true,
      "LinkMigrationSaveEachAsAdded": false,
      "GenerateMigrationComment": true,
      "WorkItemIDs": null,
      "MaxRevisions": 0,
      "NodeStructureEnricherEnabled": false,
      "UseCommonNodeStructureEnricherConfig": false,
      "StopMigrationOnMissingAreaIterationNodes": false,
      "NodeBasePaths": [],
      "AreaMaps": {},
      "IterationMaps": {},
      "MaxGracefulFailures": 0
    }

  ],
  "Endpoints": {
    "AzureDevOpsEndpoints": [
      {
        "name": "Source",
        "$type": "AzureDevOpsEndpointOptions",
        "Organisation": "url",
        "Project": "proj",
        "AuthenticationMode": "Prompt",
        "AccessToken": "pat",
        "EndpointEnrichers": null
      },
      {
        "Name": "Target",
        "$type": "AzureDevOpsEndpointOptions",
        "Organisation": "url/",
        "Project": "proj",
        "AuthenticationMode": "AccessToken",
        "AccessToken": "pat",
        "EndpointEnrichers": null
      }
    ]
  }
}

Relevant log output

Response Code:BadRequest

{"$id":"1","innerException":null,"message":"The requested REST API version of 6.0 is out of range for this server. The latest REST API version this server supports is 5.1.","typeName":"Microsoft.VisualStudio.Services.WebApi.VssVersionOutOfRangeException, Microsoft.VisualStudio.Services.WebApi","typeKey":"VssVersionOutOfRangeException","errorCode":0,"eventId":3000}
------------------------------------

System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is available to read an object of type 'RestResultDefinition`1' from content with media type 'text/html'.

   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)

   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)

   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, IEnumerable`1 formatters)

   at MigrationTools.Endpoints.AzureDevOpsEndpoint.<GetApiDefinitionsAsync>d__9`1.MoveNext() in C:\Users\g13228\workspace\azure-devops-migration-tools 3\azure-devops-migration-tools\src\MigrationTools.Clients.AzureDevops.Rest\Endpoints\AzureDevOpsEndpoint.cs:line 186

What happened?

My original error was that the REST API version 6.0 is out of range for my server. I went ahead and updated all references of the API 6.0 to 5.1 so my server could support it.

My current error is the "System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is available to read an object of type 'RestResultDefinition`1' from content with media type 'text/html'." I can't seem to find any references of this online and wondering if someone can point me in the right direction. Not sure what I am missing here, all other processors are working well

Thanks

Debug in Visual Studio

  • Visual Studio Debug

It sounds like 5.1 does not support the features being accessed. 6.0 would be the minimum...

You would need to use 7.2 if 6 is no longer supported.... but Im not sure what 2019 supports

I see - thanks for your help!

@MrHinsh You find the current REST API - AzD version mapping table at Mapping Table. 2019 only supports REST API version 5.x.

Then it looks like the pipeline migrator is not supported in 2019. We need 6.1+ for it to work.

@norschel is there a way to detect the version of TFS from the API?

Hi Everyone,

I am using the migration tool to migrate the pipelines from one organization to another in Azure Devops. I am getting the below error. Can anyone please help me with this?

[15:09:40 FTL] Error while running AzureDevOpsPipelineProcessor
System.NullReferenceException: Object reference not set to an instance of an object.
at MigrationTools.Processors.AzureDevOpsPipelineProcessor.d__17.MoveNext() in D:\a\1\s\src\MigrationTools.Clients.AzureDevops.Rest\Processors\AzureDevOpsPipelineProcessor.cs:line 304
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MigrationTools.Processors.AzureDevOpsPipelineProcessor.d__9.MoveNext() in D:\a\1\s\src\MigrationTools.Clients.AzureDevops.Rest\Processors\AzureDevOpsPipelineProcessor.cs:line 95
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MigrationTools.Processors.AzureDevOpsPipelineProcessor.InternalExecute() in D:\a\1\s\src\MigrationTools.Clients.AzureDevops.Rest\Processors\AzureDevOpsPipelineProcessor.cs:line 49
at MigrationTools.Processors.Processor.Execute() in D:\a\1\s\src\MigrationTools\Processors\Processor.cs:line 106

Please create a new thread @madhuripawar2212; this is a different topic.

When you do post, attach your config and logs.

Then it looks like the pipeline migrator is not supported in 2019. We need 6.1+ for it to work.

@norschel is there a way to detect the version of TFS from the API?

In case of WorkItemMigrationConfig, you can ask the TfsProjectCollection class for serverversion, e.g.:

y = new TfsTeamProjectCollection(TfsConfig.Collection);
Log.Debug(y.ServerDataProvider.ServerVersion);

The result is for example:
ServerVersion = "Dev19.M225.3" (AzD 2022) .

For the REST API you can call any REST API (without providing the api-version) and then check the content-type of the response header. The result in this case is for example:
Content-Type: application/json; charset=utf-8; api-version=5.1-preview.1