[Repo Assist] feat(proxy): rebuild GraphQL responses with accessible items after DIFC filtering#2330
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
…FC filtering
Previously, when DIFC filtering removed any items from a GraphQL collection
response, the proxy returned {"data":null} — even when accessible items
remained. This caused the gh CLI to see an empty result instead of the items
the agent is actually allowed to access.
Add RebuildGraphQLCollectionResponse in graphql.go which:
- Makes a deep copy of the original GraphQL response (JSON round-trip)
- Replaces the nodes array at the first known collection path:
data.repository.{issues,pullRequests,discussions,discussionCategories}.nodes
data.search.nodes
- Preserves all other fields (totalCount, pageInfo, etc.)
- Returns nil if the response doesn't match a known collection path
Update handler.go Phase 5 to use this when graphQLBody != nil and items
are filtered: instead of writing {"data":null} and returning, we call
RebuildGraphQLCollectionResponse and set finalData to the rebuilt response.
If the response shape is unrecognized (single-object query, etc.) we still
fall back to writeEmptyResponse.
Add TestRebuildGraphQLCollectionResponse with 9 subtests covering:
- All four repo collection fields (issues, pullRequests, discussions, discussionCategories)
- data.search.nodes
- Empty accessible items (all filtered)
- Immutability (original data not modified)
- nil / flat-array inputs returning nil
- Objects with data key but no collection field returning nil
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
54 tasks
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.
🤖 This is an automated PR from Repo Assist.
Summary
When DIFC filtering removes some (but not all) items from a GraphQL collection response, the proxy previously returned
{"data":null}— even when accessible items remained. This meant theghCLI would see an empty result instead of the items the agent is actually allowed to access.This PR adds
RebuildGraphQLCollectionResponsewhich:nodesarray at the first matching collection path:data.repository.issues.nodesdata.repository.pullRequests.nodesdata.repository.discussions.nodesdata.repository.discussionCategories.nodesdata.search.nodestotalCount,pageInfo, cursor fields, etc.)nilwhen the response doesn't match a known collection path (single-object queries, viewer queries, etc.), allowing the existingwriteEmptyResponsefallback to handle those casesHow
graphql.go: NewRebuildGraphQLCollectionResponse(originalData interface{}, accessibleItems []interface{}) interface{}function withgraphqlCollectionRepoFieldsvar listing the four repo collection fields. The paths mirror the guard'sGRAPHQL_COLLECTION_FIELDSconstant inhelpers.rs.handler.goPhase 5: replace theelse if graphQLBody != nilblock:Before — always returned
{"data":null}on any filtering:After — rebuilds the response with only the accessible nodes:
Trade-offs
nodespaths are supported. GraphQL queries that return data in other shapes (e.g.viewer, custom projections) still fall back to{"data":null}— this matches the guard's ownextract_graphql_nodescoverage.Test Status
TestRebuildGraphQLCollectionResponsewith 9 subtests covering all four repo fields,data.search.nodes, empty accessible items, immutability of the original data, and nil/unrecognized inputs.go.modrequires Go 1.25.0 andproxy.golang.orgis firewalled. CI will validate.Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.