Optimize jq schema middleware scalar handling and de-risk gojq comment drift#4211
Merged
Optimize jq schema middleware scalar handling and de-risk gojq comment drift#4211
Conversation
…vior Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/15bd8ed9-22bf-49cb-838f-e2757f10a2ae Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review gojq module for jq schema middleware
Optimize jq schema middleware scalar handling and de-risk gojq comment drift
Apr 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the jq schema middleware’s large-payload schema extraction path by avoiding an unnecessary JSON unmarshal round-trip for native scalar payloads, while also making gojq-related comments less version-pinned and adding a focused regression test.
Changes:
- Extend the “native JSON-compatible passthrough” in
WrapToolHandlerto include scalar types (string,float64,bool) in addition to maps/slices. - Reword gojq-related comments to avoid pinning behavior to a specific gojq version and clarify iterator consumption rationale.
- Add a regression test ensuring large scalar payloads return
PayloadMetadatawith the expected scalar schema type.
Show a summary per file
| File | Description |
|---|---|
| internal/middleware/jqschema.go | Extends schema generation’s native passthrough to scalar types and updates gojq/iterator comments for long-term accuracy. |
| internal/middleware/jqschema_test.go | Adds coverage for large scalar payloads to validate metadata + correct schema typing. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This was referenced Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The jq schema middleware already used gojq well, but had a few low-cost gaps from the module review: scalar payloads still took a JSON round-trip in the large-payload path, comments were version-pinned, and iterator consumption behavior could be clearer. This PR makes those focused improvements without changing middleware contracts.
Schema extraction path: native scalar passthrough
WrapToolHandlerfrom{map, slice}to also include JSON scalar types:string,float64,bool.Comment cleanup for long-term accuracy
Iterator behavior documentation
applyJqSchemawhy only oneNext()call is consumed and why no drain is required (synchronous iterator, no background goroutines).Focused regression coverage
PayloadMetadataand correct schema types (string,number,boolean).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build952800513/b513/launcher.test /tmp/go-build952800513/b513/launcher.test -test.testlogfile=/tmp/go-build952800513/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build952800513/b476/vet.cfg g_.a -I x_amd64/vet --gdwarf-5 grpcsync -o x_amd64/vet -o .cfg 9579546/b287/ 64/pkg/tool/linu-nilfunc -p os/exec -lang=go1.25 64/pkg/tool/linu-buildtags(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build952800513/b495/config.test /tmp/go-build952800513/b495/config.test -test.testlogfile=/tmp/go-build952800513/b495/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build952800513/b337/vet.cfg @v1.1.3/cpu/arm/go1.25.8 9579546/b151/ x_amd64/vet --gdwarf-5 nal/encoding/tag-atomic -o x_amd64/vet 9579�� g_.a -trimpath x_amd64/vet -p 64 -lang=go1.25 x_amd64/vet(dns block)nonexistent.local/tmp/go-build952800513/b513/launcher.test /tmp/go-build952800513/b513/launcher.test -test.testlogfile=/tmp/go-build952800513/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build952800513/b476/vet.cfg g_.a -I x_amd64/vet --gdwarf-5 grpcsync -o x_amd64/vet -o .cfg 9579546/b287/ 64/pkg/tool/linu-nilfunc -p os/exec -lang=go1.25 64/pkg/tool/linu-buildtags(dns block)slow.example.com/tmp/go-build952800513/b513/launcher.test /tmp/go-build952800513/b513/launcher.test -test.testlogfile=/tmp/go-build952800513/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build952800513/b476/vet.cfg g_.a -I x_amd64/vet --gdwarf-5 grpcsync -o x_amd64/vet -o .cfg 9579546/b287/ 64/pkg/tool/linu-nilfunc -p os/exec -lang=go1.25 64/pkg/tool/linu-buildtags(dns block)this-host-does-not-exist-12345.com/tmp/go-build952800513/b522/mcp.test /tmp/go-build952800513/b522/mcp.test -test.testlogfile=/tmp/go-build952800513/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s 9579�� .cfg -I x_amd64/vet us.pb.go g/grpc/grpclog/i/usr/bin/runc -o x_amd64/vet .cfg�� 9579546/b458/_pkg_.a -plugin-opt=/usr/libexec/gcc/x86-ifaceassert x_amd64/vet -plugin-opt=-pasbash contextprotocol//usr/bin/runc -plugin-opt=-pas--version x_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either: