Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set AreaPath of a new bug in Azure Devops

When I programmatically create a new bug and set the area path to this:

VssBasicCredential credentials = new VssBasicCredential(string.Empty, personalAccessToken);
new JsonPatchOperation()
{
   Operation = Operation.Add,
   Path = "/fields/System.AreaPath",
   Value = "Project"
},

WorkItem bug = await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").ConfigureAwait(false);

I get this error:

TF401346: Invalid Area/Iteration id given for work item -1, field 'System.AreaId'.

I think this is a bug, this area path exists in ADO.

like image 887
merhoo Avatar asked Nov 17 '25 05:11

merhoo


2 Answers

In case this workaround helps others - the error code TF401345 is the similar error message with different resolution.

TF401345: Area path for work item -1 is invalid

The Area Path is not the problem - we identified the fix here as too large of a payload in Repro Steps field. The error message is extremely misleading - just prune down the payload for the field that is too large and chunk it into the ADO Bug discussion. For us an image capture was overflowing the allotted data buffer.

like image 151
SliverNinja - MSFT Avatar answered Nov 20 '25 03:11

SliverNinja - MSFT


The issue was not the area path but another field, for whatever reason ADO pointed to the area path as the issue. Try adding each field one by one, or area field alone to see if it fixes the issue. This is the trimmed down version of my code.

JsonPatchDocument patchDocument = new JsonPatchDocument
{

     //add fields and their values to your patch document
     new JsonPatchOperation()
     {
         Operation = Operation.Add,
         Path = "/fields/System.Title",
         Value = $"{tag} for PR #{pullRequest.PullRequestId} changes in build {buildNumber} PlannerBuildArtifact."
      },

      new JsonPatchOperation()
      {
          Operation = Operation.Add,
          Path = "/fields/System.AreaPath",
          Value = "Project\\Planner\\Service"
      }
};
try
{
      using VssConnection connection = new VssConnection(Uri, this._credentials);
      using WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
      return await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, Project, "Bug").ConfigureAwait(false);
}
catch (VssException e)
{
      _log.LogError("Unable to create work item", e);
      throw;
}
like image 21
merhoo Avatar answered Nov 20 '25 02:11

merhoo