Fix test result outcome filtering#1182
Conversation
Avoid sending the invalid Azure DevOps result-details filter expression and filter requested outcomes client-side after fetching result details. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1182 +/- ##
=======================================
Coverage ? 90.25%
=======================================
Files ? 19
Lines ? 2124
Branches ? 499
=======================================
Hits ? 1917
Misses ? 111
Partials ? 96
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Updated this PR to restore server-side filtering with the correct filter format, discovered by inspecting ADO web client network traffic. The API accepts unquoted values, comma-separated for multiple outcomes: The original code's only mistake was quoting the values ( You can verify the filter format works directly (no auth needed, public project):
The unit tests remain mocked so can't prove the filter string is accepted server-side, but the above URLs demonstrate it. |
32a281d to
4dd2308
Compare
The ADO API accepts: Outcome eq Failed,Passed (unquoted, comma-separated). The original code used quoted strings which the API rejects. Restore server-side filtering with the correct syntax instead of filtering client-side after fetching all results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4dd2308 to
01691e2
Compare
Note
This PR description was drafted with GitHub Copilot assistance.
Fixes #1129
Avoid sending the invalid Azure DevOps result-details
$filterexpression foroutcomesintestplan_show_test_results_from_build_id.The current implementation builds an expression like:
Azure DevOps rejects this for the result-details endpoint, this is what I got in Copilot:
Cause
This is because of a bug in test-plans.ts, where it assumed values should be quoted and joined with "or" when what actually is expected by the API is unquoted and joined with comma:
https://github.com/microsoft/azure-devops-mcp/blob/main/src/tools/test-plans.ts#L431-L432
Proof -- this example working URL filters for "failed or passed" and contains
Outcome%20eq%20Failed%2CPassedie unquoted comma separated.GitHub issue number
#1129
Associated Risks
Relies on the filter syntax, which is not well (or at all?) documented, however the existing code already relies on this. Plus, this repo is owned by the Azure Devops team, who can presumably be confident of what is OK to rely on.
✅ PR Checklist
🧪 How did you test it?
npm test -- --runTestsByPath test/src/tools/test-plan.test.ts --runInBandnpm run validate-tools