Skip to content

[Repo Assist] fix(rust-guard): remove write-only owner-type cache and simplify get_issue_author_association#4339

Merged
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-4329-backend-dead-code-a21fa17cdef69ab6
Apr 22, 2026
Merged

[Repo Assist] fix(rust-guard): remove write-only owner-type cache and simplify get_issue_author_association#4339
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-4329-backend-dead-code-a21fa17cdef69ab6

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Closes #4329

Root Cause

Two dead-code / duplication issues in guards/github-guard/rust-guard/src/labels/backend.rs:

Issue 1 — Write-only repo_owner_type_cache
set_cached_owner_is_org (and the repo_owner_type_cache it writes to) existed in anticipation of a get_cached_owner_is_org reader that was never wired up. Every is_repo_private_with_callback call acquired a Mutex lock and inserted into a HashMap that grew without bound and was never consulted. Classic incomplete-feature footgun.

Issue 2 — get_issue_author_association_with_callback is a strict subset of get_issue_author_info_with_callback
Both functions made the same issue_read backend call, parsed the same args, allocated the same buffer size, and extracted author_association via the identical two-field fallback. The only difference was that the info variant also extracted author_login. This 35-line duplication meant any future change to the issue_read call shape had to be applied in two places.

Fix

  1. Remove repo_owner_type_cache, set_cached_owner_is_org, and the call site inside is_repo_private_with_callback. The debug log line is retained; only the cache write is dropped.

  2. Replace the 35-line body of get_issue_author_association_with_callback with a one-liner that delegates to get_issue_author_info_with_callback:

    get_issue_author_info_with_callback(callback, owner, repo, issue_number)
        .and_then(|info| info.author_association)

Trade-offs

  • Purely mechanical changes; zero semantic change.
  • Removes 41 lines net. The get_issue_author_association public API is unchanged.

Test Status

  • cargo build — compiles without warnings
  • cargo test322 / 322 tests pass
  • ⚠️ Go build/test skipped — proxy.golang.org blocked by network firewall (pre-existing infrastructure limitation)

Generated by Repo Assist · ● 3M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

…issue_author_association

Closes #4329

Two dead-code / duplication fixes in backend.rs:

1. Remove repo_owner_type_cache and set_cached_owner_is_org.
   The cache was written to on every is_repo_private_with_callback call
   but never read — no get_cached_owner_is_org exists anywhere in the
   codebase. This wasted a Mutex acquisition and grew a HashMap
   indefinitely without ever being consulted. The piggyback log line is
   retained; only the cache write is dropped.

2. Replace the 35-line get_issue_author_association_with_callback body
   with a one-liner that delegates to get_issue_author_info_with_callback.
   Both functions made the identical issue_read call and parsed the same
   fields; the only difference was that the info variant also extracted
   author_login. Any future change to the issue_read fetch path now
   needs to be made in exactly one place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review April 22, 2026 14:34
Copilot AI review requested due to automatic review settings April 22, 2026 14:34
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 dead, write-only caching and reduces duplicated backend-call logic in Rust Guard’s labels backend layer (backend.rs), improving efficiency and maintainability without changing the public API.

Changes:

  • Removed the unused repo_owner_type_cache and its write path from is_repo_private_with_callback (retaining debug logging).
  • Simplified get_issue_author_association_with_callback by delegating to get_issue_author_info_with_callback to eliminate duplicated parsing/callback logic.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/backend.rs Deletes write-only owner-type cache and de-duplicates issue author-association fetching logic via delegation

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 4a2e02a into main Apr 22, 2026
25 of 26 checks passed
@lpcox lpcox deleted the repo-assist/fix-issue-4329-backend-dead-code-a21fa17cdef69ab6 branch April 22, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rust-guard] Rust Guard: Two dead-code / duplication fixes in backend.rs

2 participants