Skip to content

rust-guard: remove dead params from issue_integrity + fix heap-allocating string comparison#2152

Merged
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-dead-parameters
Mar 19, 2026
Merged

rust-guard: remove dead params from issue_integrity + fix heap-allocating string comparison#2152
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-dead-parameters

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Two small cleanup items in the Rust guard: issue_integrity carried two never-read parameters (_owner, _repo) that forced callers to perform unnecessary string splits, and tool_rules.rs was heap-allocating a String on every actions_get call just to do an equality check.

Changes

  • labels/helpers.rs — drop _owner: &str and _repo: &str from issue_integrity signature
  • labels/response_items.rs — remove repo_owner split (existed solely to fill the dead arg)
  • labels/response_paths.rs — remove owner split + stale // Extract owner from repo for owner check comment
  • labels/mod.rs — update all 10 test call sites to match new signature
  • labels/tool_rules.rs — replace heap-allocating comparison with zero-allocation .as_str() idiom:
// Before — allocates on every actions_get call
tool_args.get("method") == Some(&Value::String("download_workflow_run_artifact".to_string()))

// After — allocation-free
tool_args.get("method").and_then(|v| v.as_str()) == Some("download_workflow_run_artifact")

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-build1926788072/b332/launcher.test /tmp/go-build1926788072/b332/launcher.test -test.testlogfile=/tmp/go-build1926788072/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1926788072/b253/vet.cfg 64/src/runtime/cgo erive-f8a9da973ea849b8.serde_dernet/http x86_64/as erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 378038/b011/syma-unsafeptr=false erive-f8a9da973e-unreachable=false _main.o eriv�� ache/go/1.25.8/x64/src/runtime/cgo1.25.8 CLzi/BTFciEBdHbS8DwRuCLzi x_amd64/vet erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet erive-f8a9da973e-atomic -Wl,-Bstatic x_amd64/vet (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1926788072/b317/config.test /tmp/go-build1926788072/b317/config.test -test.testlogfile=/tmp/go-build1926788072/b317/testlog.txt -test.paniconexit0 -test.timeout=10m0s 2c9e�� 64/src/runtime/cgo -gnu/lib/libstd-267b04dbd87607fbgithub.com/tetratelabs/wazero/internal/platform x_amd64/compile -gnu/lib/libobje/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 378038/b009/ -gnu/lib/libaddr-unreachable=false x_amd64/compile -gnu�� ; 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 -gnu/lib/libstd_detect-3c01aa300-nolocalimports x_amd64/vet -gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet ry 64-REDACTED-linux-unreachable=false x_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build1926788072/b332/launcher.test /tmp/go-build1926788072/b332/launcher.test -test.testlogfile=/tmp/go-build1926788072/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1926788072/b253/vet.cfg 64/src/runtime/cgo erive-f8a9da973ea849b8.serde_dernet/http x86_64/as erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 378038/b011/syma-unsafeptr=false erive-f8a9da973e-unreachable=false _main.o eriv�� ache/go/1.25.8/x64/src/runtime/cgo1.25.8 CLzi/BTFciEBdHbS8DwRuCLzi x_amd64/vet erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet erive-f8a9da973e-atomic -Wl,-Bstatic x_amd64/vet (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build1926788072/b332/launcher.test /tmp/go-build1926788072/b332/launcher.test -test.testlogfile=/tmp/go-build1926788072/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1926788072/b253/vet.cfg 64/src/runtime/cgo erive-f8a9da973ea849b8.serde_dernet/http x86_64/as erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 378038/b011/syma-unsafeptr=false erive-f8a9da973e-unreachable=false _main.o eriv�� ache/go/1.25.8/x64/src/runtime/cgo1.25.8 CLzi/BTFciEBdHbS8DwRuCLzi x_amd64/vet erive-f8a9da973e/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet erive-f8a9da973e-atomic -Wl,-Bstatic x_amd64/vet (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1926788072/b341/mcp.test /tmp/go-build1926788072/b341/mcp.test -test.testlogfile=/tmp/go-build1926788072/b341/testlog.txt -test.paniconexit0 -test.timeout=10m0s o_.o�� 64/src/net a/dsa.go x_amd64/vet -p internal/runtime--version -lang=go1.25 x_amd64/vet -o ew@v1.1.1/spew/bypass.go ew@v1.1.1/spew/common.go x_amd64/vet -p 378038/b107/_cgo-qE -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:


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…string comparison

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove dead parameters from issue_integrity and fix string comparison rust-guard: remove dead params from issue_integrity + fix heap-allocating string comparison Mar 19, 2026
Copilot AI requested a review from lpcox March 19, 2026 15:14
@lpcox lpcox marked this pull request as ready for review March 19, 2026 15:19
Copilot AI review requested due to automatic review settings March 19, 2026 15:19
@lpcox lpcox merged commit 0f464bf into main Mar 19, 2026
15 checks passed
@lpcox lpcox deleted the copilot/rust-guard-remove-dead-parameters branch March 19, 2026 15:19
Copy link
Contributor

Copilot AI left a comment

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 cleans up the GitHub Rust guard’s integrity labeling API by removing unused issue_integrity parameters (and the caller-side repo splitting they forced), and improves actions_get handling by replacing a heap-allocating JSON string comparison with an allocation-free check.

Changes:

  • Remove unused _owner / _repo parameters from issue_integrity and update all call sites/tests accordingly.
  • Delete now-unnecessary owner / repo_owner string splitting in response labeling paths/items.
  • Avoid per-call heap allocation in tool_rules.rs by comparing method via as_str().

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/helpers.rs Drops dead issue_integrity params (signature cleanup).
guards/github-guard/rust-guard/src/labels/response_items.rs Removes repo-owner split that existed only for the dead args.
guards/github-guard/rust-guard/src/labels/response_paths.rs Removes owner split and updates issue_integrity invocation.
guards/github-guard/rust-guard/src/labels/mod.rs Updates tests to match the new issue_integrity signature.
guards/github-guard/rust-guard/src/labels/tool_rules.rs Replaces allocating JSON string equality with an allocation-free as_str() comparison.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 808 to 817
/// Determine integrity level for an issue
/// Rules:
/// - private repo issues => approved
/// - public repo issues => no integrity
pub fn issue_integrity(
item: &Value,
repo_full_name: &str,
_owner: &str,
_repo: &str,
repo_private: bool,
ctx: &PolicyContext,
) -> Vec<String> {
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.

[rust-guard] Rust Guard: Remove dead parameters from issue_integrity + fix heap-allocating string comparison

3 participants