Skip to content

Handle missing pull request thread arrays#1184

Merged
danhellem merged 1 commit intomicrosoft:mainfrom
danmoseley:azure-devops-mcp-pr-thread-result-shape
Apr 28, 2026
Merged

Handle missing pull request thread arrays#1184
danhellem merged 1 commit intomicrosoft:mainfrom
danmoseley:azure-devops-mcp-pr-thread-result-shape

Conversation

@danmoseley
Copy link
Copy Markdown
Member

@danmoseley danmoseley commented Apr 25, 2026

Note

This PR description was drafted with GitHub Copilot assistance.

Fixes #1180

Normalize missing pull request thread responses in repo_list_pull_request_threads.

If gitApi.getThreads(...) returns undefined, JSON.stringify(undefined) also returns undefined, which can produce an invalid MCP tool result because content[0].text must be a string, from Copilot here:

Tool: ado-dnceng-repo_list_pull_request_threads
Args: { "repositoryId": "copilot-agent-runtime", "project": "copilot-agent-runtime", "pullRequestId": 6536, "status": "Active" }
Result: Invalid tools/call result ... content[0].text expected string, received undefined

This PR normalizes missing thread responses to [] and keeps the rest of the filtering/paging/mapping logic array-based.

GitHub issue number

#1180

Associated Risks

Low. The intended behavior for a missing thread array is to return an empty JSON array rather than an invalid MCP result shape.

PR Checklist

  • I have read the contribution guidelines
  • I have read the code of conduct guidelines
  • Title of the pull request is clear and informative.
  • 👌 Code hygiene
  • 🔭 Telemetry added, updated, or N/A
  • 📄 Documentation added, updated, or N/A
  • 🛡️ Automated tests added, or N/A

🧪 How did you test it?

  • npm test -- --runTestsByPath test/src/tools/repositories.test.ts --runInBand
  • npm run validate-tools

Normalize missing getThreads responses to an empty array so the MCP result text is always a string.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danmoseley danmoseley requested a review from a team as a code owner April 25, 2026 08:34
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@546e37d). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1184   +/-   ##
=======================================
  Coverage        ?   90.25%           
=======================================
  Files           ?       19           
  Lines           ?     2124           
  Branches        ?      499           
=======================================
  Hits            ?     1917           
  Misses          ?      111           
  Partials        ?       96           
Flag Coverage Δ
unittests 90.25% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danmoseley
Copy link
Copy Markdown
Member Author

example of impact in Copilot CLI session, I just got it again--
image

@danhellem danhellem merged commit 38985b9 into microsoft:main Apr 28, 2026
6 checks passed
@danmoseley danmoseley deleted the azure-devops-mcp-pr-thread-result-shape branch April 28, 2026 01:23
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.

Bug: repo_list_pull_request_threads can return invalid MCP content when no thread array is returned

3 participants