Repository navigation
Reuse bounded GraphQL parses and cover Unicode rewrite offsets - #16757
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked through any surface. No security regression evidence found.
|
There was a problem hiding this comment.
🔵 Needs a closer look
Shared AST reuse couples operation selection, alias rejection, security routing, and guard-field injection, requiring human review of cache lifecycle, source-offset consistency, and fail-closed behavior when query text is rebuilt.
No open issues 🎉
What changed in this PR
This PR reduces repeated parsing in the proxy’s GraphQL guard and adds Unicode regression coverage, addressing issue #16696 without changing the parser dependency.
Changes:
- Reuse request-local parses across operation selection, routing, alias checks, and field injection; reparse when query text changes.
- Add Unicode offset, cache reuse, invalidation, and injection-idempotence tests, plus PR-path benchmarks.
- Document parsing limits, rune-based offsets, and schema-validation boundaries.
| File | Description |
|---|---|
| internal/proxy/read_only.go | Uses the shared parse cache during operation selection. |
| internal/proxy/read_only_test.go | Tests Unicode preservation when selecting operations and fragments. |
| internal/proxy/handler.go | Shares a request-local cache across GraphQL processing stages. |
| internal/proxy/graphql.go | Adds bounded parse caching for routing and alias checks. |
| internal/proxy/graphql_rewrite.go | Reuses cached parses during PR guard-field injection. |
| internal/proxy/graphql_pr_guard_test.go | Adds Unicode injection tests and guard-path benchmarks. |
| internal/proxy/graphql_parse_test.go | Tests cache reuse, invalidation, errors, and pipeline integration. |
| docs/PROXY_MODE.md | Documents parser limits, cache lifetime, and rewrite-offset requirements. |
Review effort: Balanced (adaptive)
The GraphQL PR guard parsed the same query up to four times, while source-preserving rewrites lacked Unicode offset coverage.