Skip to content

Simplify MCP content handling in the payload fast path - #16615

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-pattern-fix-again
Nov 15, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-pattern-fix-again

Conversation

@lpcox

@lpcox lpcox commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

The payload fast path duplicates slice-shape handling after normalization. Because normalization skips non-map entries, normalized length alone cannot establish a single-item envelope.

  • Refactor: Replace identical switch branches with one []any raw-length guard.
  • Preserve semantics: Keep single-item checks and strict SDK conversion unchanged.
  • Regression coverage: Verify oversized non-map entries before or after a text item trigger storage and remain in the stored payload.

@lpcox lpcox changed the title [WIP] Fix duplicate MCP content slice handling code Simplify MCP content handling in the payload fast path Nov 15, 2026
@lpcox
lpcox marked this pull request as ready for review November 15, 2026 20:18
Copilot AI adaptive review requested due to automatic review settings November 15, 2026 20:18

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

There are no active review issues for the middleware payload fast-path simplification.

No open issues 🎉

What changed in this PR

Simplifies the middleware’s payload fast path by removing duplicate content-slice handling while preserving single-item checks and leaving strict SDK conversion unchanged.

Changes:

  • Replaces the dual-shape switch with a raw []any length guard so normalization cannot hide extra entries.
  • Adds regression coverage confirming oversized non-map entries before or after text trigger storage and remain in the stored payload.
File Description
internal/​middleware/​jqschema.go Simplifies the fast-path guard while preserving raw entry counts.
internal/​middleware/​jqschema_test.go Tests payload preservation with non-map entries in both positions.

Review effort: Balanced (dynamic)

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) no write tools in catalog BLOCKED ⚠️
C CLI reads data ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh unauthenticated, not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated, not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

Details:

  • Part A: list_issues, list_pull_requests, get_file_contents(README.md), list_commits all returned data via the gateway-backed github CLI.
  • Part B: the exposed MCP tool catalog contains only 23 read-only tools (get_commit, get_file_contents, get_label, get_latest_release, get_release_by_tag, get_tag, issue_read, list_branches, list_commits, list_issue_fields, list_issue_types, list_issues, list_pull_requests, list_releases, list_repository_collaborators, list_starred_repositories, list_tags, pull_request_read, search_code, search_commits, search_issues, search_pull_requests, search_repositories). None of the targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) are present, so no write could be attempted — this reflects gh-aw's GITHUB_READ_ONLY=1 backend defense, not independent evidence of mcpg's own gateway-level DIFC/guard blocking.
  • Part C: reads via the proxied github CLI succeeded.
  • Part D/E: gh auth status reported no authenticated host, so REST/GraphQL write attempts were not performed; the token-scope boundary could not be exercised this run.

No write leaked on any surface that was reachable. Gaps (absent write tools, unauthenticated gh) prevent full confirmation of gateway-level write blocking for this run; this is a known methodology limitation for the tools.github: wrapper, not a detected regression.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit fb36e77 into main Nov 15, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-pattern-fix-again branch November 15, 2026 20:44
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.

[duplicate-code] Duplicate Code Pattern: Dual-shape MCP content slice handling

3 participants