Sitelet https://github.com/github/github-mcp-server/pull/3772
Skip to content

Avoid overflow in validation error capacity - #3772

Merged
omgitsads merged 1 commit into
mainfrom
omgitsads-fix-allocation-overflow
Nov 9, 2026
Merged

omgitsads merged 1 commit into
mainfrom
omgitsads-fix-allocation-overflow

Conversation

@omgitsads

Copy link
Copy Markdown
Member

Summary

Avoid preallocating the validation-error parts slice from an unchecked len(errors) + 1 capacity calculation, while preserving the formatted error output.

Why

The public code-scanning alert flags the capacity calculation as potentially overflowing when formatting GitHub validation errors.

What changed

  • Removed the capacity calculation based on the number of API validation errors.
  • Added a regression test covering formatting a large validation-error list.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • N/A — no MCP tools changed.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered — no output or API limit behavior changed; the fix avoids preallocating capacity from the API-provided error count.

Tool renaming

  • I am renaming tools as part of this PR (e.g. as part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Results: script/lint — passed; script/test — passed.

Docs

  • Not needed
  • Updated (README / docs / examples)

@omgitsads
omgitsads requested a review from a team as a code owner November 9, 2026 11:34
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported, and the change includes regression coverage for the overflow-prone error-list formatting path.

No open issues 🎉

What changed in this PR

This pull request prevents integer overflow when formatting GitHub validation errors by removing unchecked slice-capacity preallocation while preserving existing output.

Changes:

  • Removes the len(errors) + 1 capacity calculation.
  • Adds regression coverage for formatting large validation-error lists.
  • Reorders test imports to follow Go formatting conventions.
File Description
pkg/​errors/​error.go Removes the overflow-prone validation-error slice capacity calculation.
pkg/​errors/​error_test.go Adds regression coverage for large validation-error lists and updates imports.

Review effort: Lite (auto)

@omgitsads
omgitsads merged commit 6fbcd00 into main Nov 9, 2026
22 checks passed
@omgitsads
omgitsads deleted the omgitsads-fix-allocation-overflow branch November 9, 2026 14:28
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.

3 participants