Skip to content

Avoid stack overflow flattening test results#1183

Open
danmoseley wants to merge 1 commit intomicrosoft:mainfrom
danmoseley:azure-devops-mcp-test-results-stack
Open

Avoid stack overflow flattening test results#1183
danmoseley wants to merge 1 commit intomicrosoft:mainfrom
danmoseley:azure-devops-mcp-test-results-stack

Conversation

@danmoseley
Copy link
Copy Markdown
Member

@danmoseley danmoseley commented Apr 25, 2026

Note

This PR description was drafted with GitHub Copilot assistance.

Fixes #1179

Avoid stack overflow when flattening large result groups in testplan_show_test_results_from_build_id.

The previous implementation used:

allResults.push(...group.results)

For very large result groups, that spreads every result as a function argument and can exceed JavaScript engine argument limits, throwing Maximum call stack size exceeded:

Tool: ado-dnceng-public-testplan_show_test_results_from_build_id
Args: { "project": "public", "buildid": 1395596 }
Result: MCP server 'ado-dnceng-public': Error fetching test results: Maximum call stack size exceeded

This PR changes the flattening to iterate results and push one item at a time. The structure of the JSON is not changed -- it's the same structure the code would produce if it didn't stack overflow the engine by using spread.

GitHub issue number

#1179

Associated Risks

This is intended to be behavior-preserving except for avoiding the spread/argument-limit failure. It does not otherwise change result fetching or output shape.
Returning very large output successfully may now expose a limitation elsewhere.

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/test-plan.test.ts --runInBand
  • npm run validate-tools

Flatten large test result groups with iteration instead of spreading them into push, which can exceed JavaScript argument limits.

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    #1183   +/-   ##
=======================================
  Coverage        ?   90.25%           
=======================================
  Files           ?       19           
  Lines           ?     2125           
  Branches        ?      498           
=======================================
  Hits            ?     1918           
  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.

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: testplan_show_test_results_from_build_id can hit Maximum call stack size exceeded on large test-result groups

2 participants