Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 4, 2025

Problem

The Set-TfsWorkItem cmdlet was failing when using the -Fields parameter with the error:

Set-TfsWorkItem: Error getting work items (You must pass in a set of valid work item Ids to the Ids parameter. The following Ids are not valid: 0..)

This prevented users from setting custom fields on work items, requiring manual work for work item management tasks.

Root Cause

In WorkItemPatchBuilderImpl.cs, when the Fields parameter was specified, the code attempted to get the work item type definition to properly parse custom fields. However, it was passing WorkItem = 0 as a parameter, which is an invalid work item ID:

var wit = Data.GetItem<WebApiWorkItemType>(new { Type = wi.Fields["System.WorkItemType"], WorkItem = 0, Project = projectName });

Solution

Changed the code to use the actual work item ID that is already available in the wi parameter:

var wit = Data.GetItem<WebApiWorkItemType>(new { Type = wi.Fields["System.WorkItemType"], WorkItem = wi.Id, Project = projectName });

Example Usage

This command will now work correctly:

Set-TfsWorkItem -WorkItem 32710953 -Fields @{"System.State" = "Active"}

The fix is minimal and surgical - it only changes the specific line causing the issue without affecting any other functionality.

Fixes #245.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] New/Set-TfsWorkItem is not working when Fields attribute is being specified Fix Set-TfsWorkItem Fields parameter error by using actual work item ID Jun 4, 2025
Copilot AI requested a review from igoravl June 4, 2025 23:52
Copilot finished work on behalf of igoravl June 4, 2025 23:52
@github-actions
Copy link

github-actions bot commented Jun 5, 2025

Test Results

  2 files   80 suites   1m 58s ⏱️
139 tests 139 ✅ 0 💤 0 ❌
278 runs  278 ✅ 0 💤 0 ❌

Results for commit 7a3e333.

♻️ This comment has been updated with latest results.

@igoravl igoravl marked this pull request as ready for review June 5, 2025 14:47
@igoravl
Copy link
Owner

igoravl commented Jun 5, 2025

Fixes #245

@igoravl igoravl merged commit 9e096ed into main Jun 5, 2025
5 checks passed
@igoravl igoravl deleted the copilot/fix-245 branch June 5, 2025 14:59
@igoravl igoravl linked an issue Jun 5, 2025 that may be closed by this pull request
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.

New/Set-TfsWorkItem is not working when Fields attribute is being specified Not possible to hard-delete Projects without confirmation

2 participants