Skip to content

fix(rust-guard): use correct JSON pointer key for search_repositories response#2407

Merged
lpcox merged 2 commits into
fix/search-bot-author-filteringfrom
copilot/sub-pr-2403
Mar 24, 2026
Merged

fix(rust-guard): use correct JSON pointer key for search_repositories response#2407
lpcox merged 2 commits into
fix/search-bot-author-filteringfrom
copilot/sub-pr-2403

Conversation

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

search_repositories fell back to reading from a repositories key (GraphQL-style) but then hardcoded /items in both per-item JSON Pointer paths and items_path, so labels would point at non-existent locations when the response used repositories.

Changes

  • response_paths.rs: Replace .or_else() chaining with an explicit if let chain that captures which key was matched ("items" vs "repositories"); use /{key}/{i} for per-item paths and /{key} for items_path.
// Before: key used was lost, paths always hardcoded to /items
let items_opt = actual_response.get("items").and_then(|v| v.as_array())
    .or_else(|| actual_response.get("repositories").and_then(|v| v.as_array()));
// ...
path: format!("/items/{}", i),     // wrong when response has "repositories"
items_path: Some("/items".to_string()),

// After: key is tracked and propagated
let (items_opt, items_key) =
    if let Some(arr) = actual_response.get("items").and_then(|v| v.as_array()) {
        (Some(arr), "items")
    } else if let Some(arr) = actual_response.get("repositories").and_then(|v| v.as_array()) {
        (Some(arr), "repositories")
    } else {
        (None, "items")
    };
// ...
path: format!("/{}/{}", items_key, i),
items_path: Some(format!("/{}", items_key)),
  • mod.rs: Two regression tests — one for repositories key producing /repositories/{i} paths, one confirming REST items key still produces /items/{i}.

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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
    • Triggering command: /tmp/go-build1933733685/b333/launcher.test /tmp/go-build1933733685/b333/launcher.test -test.testlogfile=/tmp/go-build1933733685/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s stup�� 1.4.1/mcp/client.go 1.4.1/mcp/cmd.go x_amd64/compile -gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -gnu/lib/libmini-unsafeptr=false (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1933733685/b318/config.test /tmp/go-build1933733685/b318/config.test -test.testlogfile=/tmp/go-build1933733685/b318/testlog.txt -test.paniconexit0 -test.timeout=10m0s ortc�� 1.4.1/internal/json/json.go v63b7rvpg x_amd64/compile -gnu/lib/libobje/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 0653420/b009/ -gnu/lib/libaddr-unreachable=false x_amd64/compile ortc�� ; then \ $GOPATH/bin/golangci-lint run --timeout=5m || echo "��� Warning: golangci-lint failed /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /logger/file_logger.go x_amd64/vet -gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet jsonrpc2 -m x_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build1933733685/b333/launcher.test /tmp/go-build1933733685/b333/launcher.test -test.testlogfile=/tmp/go-build1933733685/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s stup�� 1.4.1/mcp/client.go 1.4.1/mcp/cmd.go x_amd64/compile -gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -gnu/lib/libmini-unsafeptr=false (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build1933733685/b333/launcher.test /tmp/go-build1933733685/b333/launcher.test -test.testlogfile=/tmp/go-build1933733685/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s stup�� 1.4.1/mcp/client.go 1.4.1/mcp/cmd.go x_amd64/compile -gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -gnu/lib/libmini-unsafeptr=false (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1933733685/b342/mcp.test /tmp/go-build1933733685/b342/mcp.test -test.testlogfile=/tmp/go-build1933733685/b342/testlog.txt -test.paniconexit0 -test.timeout=10m0s 0653�� ache/go/1.25.8/x64/src/runtime/cgo1.25.8 7Qi_/C3HkLvmnQF0p4DmP7Qi_ x_amd64/vet erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet erive-f8a9da973e-atomic -m x_amd64/vet /cpu�� ache/go/1.25.8/x-errorsas ache/go/1.25.8/x-ifaceassert x_amd64/vet -p internal/unsafehdocker-cli-plugin-metadata -lang=go1.25 x_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix rust-guard to handle GraphQL-format search results and bot-author filtering fix(rust-guard): use correct JSON pointer key for search_repositories response Mar 24, 2026
Copilot AI requested a review from lpcox March 24, 2026 03:21
@lpcox lpcox marked this pull request as ready for review March 24, 2026 03:36
Copilot AI review requested due to automatic review settings March 24, 2026 03:36
@lpcox lpcox merged commit 8f5bfd1 into fix/search-bot-author-filtering Mar 24, 2026
7 checks passed
@lpcox lpcox deleted the copilot/sub-pr-2403 branch March 24, 2026 03:37

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.

Pull request overview

This PR fixes path-based labeling for the search_repositories tool when the response uses a GraphQL-style repositories array instead of the REST-style items array, ensuring RFC 6901 JSON Pointer paths and items_path point at real locations in the response.

Changes:

  • Track which collection key was matched (items vs repositories) and use it when constructing per-item JSON Pointer paths and items_path.
  • Add regression tests covering both repositories (GraphQL-style) and items (REST-style) response shapes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
guards/github-guard/rust-guard/src/labels/response_paths.rs Preserve the matched array key and use it to build correct per-item paths (/{key}/{i}) and items_path (/{key}) for search_repositories.
guards/github-guard/rust-guard/src/labels/mod.rs Add regression tests validating correct path prefixes for both repositories and items response formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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