Skip to content

fix(guard): remove unused org-ownership functions blocking release#4290

Merged
lpcox merged 2 commits intomainfrom
fix/remove-dead-rust-guard-code
Apr 21, 2026
Merged

fix(guard): remove unused org-ownership functions blocking release#4290
lpcox merged 2 commits intomainfrom
fix/remove-dead-rust-guard-code

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 21, 2026

Problem

The Release workflow (run #24740822133) failed in the docker job because the Rust guard build has -D warnings enabled and two functions trigger dead_code warnings:

error: function `get_cached_owner_is_org` is never used
  --> src/labels/backend.rs:63

error: function `is_repo_org_owned` is never used
  --> src/labels/backend.rs:282

Fix

Remove the two unused functions (get_cached_owner_is_org and is_repo_org_owned) and their associated tests. These were added for future org-ownership detection but are never called from production code.

The cache setter (set_cached_owner_is_org) is retained — it's called during is_repo_private lookups to populate the owner-type cache for when these functions are needed later.

Removed

  • get_cached_owner_is_org() — private cache reader (line 63)
  • is_repo_org_owned() — public API (line 282)
  • test_is_repo_org_owned_uses_cache — test
  • test_is_repo_org_owned_empty_args — test

Verification

make agent-finished passes (format, build, lint, all tests including Rust guard).

Remove get_cached_owner_is_org and is_repo_org_owned which are never
called outside of tests. These were added for future use but currently
trigger -D warnings (dead_code) failures in CI release builds.

The cache setter (set_cached_owner_is_org) is retained as it's called
during is_repo_private lookups to populate the cache.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 19:16
Copy link
Copy Markdown
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

Removes unused org-ownership helper APIs from the Rust guard to unblock release builds that treat warnings as errors.

Changes:

  • Deleted unused cache reader get_cached_owner_is_org and public API is_repo_org_owned that were triggering dead_code warnings.
  • Removed the associated unit tests for is_repo_org_owned.
  • Kept owner-type cache population during is_repo_private lookups.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/backend.rs Removes unused org-ownership functions/tests to eliminate dead_code warnings during release builds.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (2)

guards/github-guard/rust-guard/src/labels/backend.rs:66

  • After removing the only read path (get_cached_owner_is_org / is_repo_org_owned), the owner-type cache is now write-only: set_cached_owner_is_org is called from is_repo_private_with_callback, but nothing ever reads repo_owner_type_cache. This adds extra work and can grow memory over the process lifetime without providing value. Consider removing the owner-type extraction/caching until there is a real consumer, or adding a bounded/evicting cache before keeping it.

This issue also appears on line 1287 of the same file.

fn set_cached_owner_is_org(repo_id: &str, is_org: bool) {
    if let Ok(mut cache) = repo_owner_type_cache().lock() {
        cache.insert(repo_id.to_string(), is_org);
    }

guards/github-guard/rust-guard/src/labels/backend.rs:1290

  • With the is_repo_org_owned tests removed, the helper clear_owner_type_cache_for_tests (defined earlier in this module) is now unused. This can reintroduce a dead_code warning when compiling tests (and can fail CI if warnings are denied). Consider deleting the helper or annotating it to suppress dead_code if you want to keep it for future tests.
        });
        assert_eq!(extract_owner_is_org(&response, "myorg/myrepo"), None);
    }
}
  • Files reviewed: 1/1 changed files
  • Comments generated: 0

Was only called by the test functions removed in the previous commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 964ae59 into main Apr 21, 2026
14 checks passed
@lpcox lpcox deleted the fix/remove-dead-rust-guard-code branch April 21, 2026 21:07
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.

2 participants