Commit 40c056f
authored
Fix wit_work_item_unlink ignoring type when url is provided (#1159)
**Fix type parameter bypass in `wit_work_item_unlink` when URL is
provided.**
The URL-match branch in the `work_item_unlink` tool only checked
`relation.url` without verifying `relation.rel` matched the requested
link type. This allowed deletion of relations whose actual type differed
from the `type` parameter (e.g., removing an `ArtifactLink` when
`type="related"` was specified). The code comment already stated "find
relations matching both rel type and url" but the implementation only
enforced the URL check.
Added `relation.rel === linkType` to the URL-match condition so both
type and URL must match before a relation is removed.
## GitHub issue number
N/A
## **Associated Risks**
- Callers that previously relied on URL-only matching (ignoring type)
will now get a "No matching relations found" error if the type doesn't
match the relation at that URL. This is the correct behavior per the
tool's documented contract.
- No breaking changes for callers that already pass consistent type +
URL combinations.
## ✅ **PR Checklist**
- [x] **I have read the [contribution
guidelines](https://github.com/microsoft/azure-devops-mcp/blob/main/CONTRIBUTING.md)**
- [x] **I have read the [code of conduct
guidelines](https://github.com/microsoft/azure-devops-mcp/blob/main/CODE_OF_CONDUCT.md)**
- [x] Title of the pull request is clear and informative.
- [x] 👌 Code hygiene
- [x] 🔭 Telemetry added, updated, or N/A — N/A
- [x] 📄 Documentation added, updated, or N/A — N/A (no doc changes
needed; tool schema/description unchanged)
- [x] 🛡️ Automated tests added, or N/A — Added
## 🧪 **How did you test it?**
Added 3 unit tests in work-items.test.ts under `work_item_unlink tool >
type + url matching`:
| Test case | Scenario | Expected |
|---|---|---|
| `type=related` + ArtifactLink URL | URL matches but `rel` is
`ArtifactLink`, not `System.LinkTypes.Related` | No deletion, returns
"No matching relations found" |
| `type=child` + ArtifactLink URL | URL matches but `rel` is
`ArtifactLink`, not `System.LinkTypes.Hierarchy-Forward` | No deletion,
returns "No matching relations found" |
| `type=related` + matching Related URL | Both URL and `rel` match |
Deletes the correct relation at index 1 |
All 3 tests pass after the fix. Before the fix, tests 1 and 2 correctly
failed (confirming the bug).1 parent 5b842c5 commit 40c056f
2 files changed
+43
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1225 | 1225 | | |
1226 | 1226 | | |
1227 | 1227 | | |
1228 | | - | |
| 1228 | + | |
1229 | 1229 | | |
1230 | 1230 | | |
1231 | 1231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2406 | 2406 | | |
2407 | 2407 | | |
2408 | 2408 | | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
2409 | 2451 | | |
2410 | 2452 | | |
2411 | 2453 | | |
| |||
0 commit comments