Skip to content

Add direct repo-scope fallback coverage in Rust guard#7274

Merged
lpcox merged 5 commits into
mainfrom
copilot/rust-guard-add-unit-tests
Jun 10, 2026
Merged

Add direct repo-scope fallback coverage in Rust guard#7274
lpcox merged 5 commits into
mainfrom
copilot/rust-guard-add-unit-tests

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

extract_repo_scope_with_query_fallback is security-relevant for issue and PR collection labeling, but only had indirect coverage through larger response-labeling tests. This change adds direct coverage for its arg-vs-query resolution behavior and simplifies duplicated items_path handling in response_paths.rs.

  • Direct coverage for repo-scope fallback

    • Adds focused unit tests for the four resolution paths in extract_repo_scope_with_query_fallback:
      • explicit owner/repo wins over query
      • fallback to query when args are absent
      • fallback to query when args are partial
      • empty result when neither source provides repo scope
  • Idiomatic items_path construction

    • Replaces three repeated if items_path.is_empty() { None } else { Some(items_path) } blocks with then_some(...)
    • Keeps behavior unchanged while removing duplicated branching in the PR, issue, and project-item response path code
  • Example

    items_path: (!items_path.is_empty()).then_some(items_path),

GitHub Advanced Security started work on behalf of lpcox June 9, 2026 15:29 View session
GitHub Advanced Security finished work on behalf of lpcox June 9, 2026 15:30
Copilot AI changed the title [WIP] Add direct unit tests for extract_repo_scope_with_query_fallback Add direct repo-scope fallback coverage in Rust guard Jun 9, 2026
Copilot finished work on behalf of lpcox June 9, 2026 15:33
Copilot AI requested a review from lpcox June 9, 2026 15:33
@lpcox lpcox marked this pull request as ready for review June 10, 2026 13:44
Copilot AI review requested due to automatic review settings June 10, 2026 13:44

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 strengthens the Rust guard’s security-relevant repo-scope resolution by adding direct unit coverage for extract_repo_scope_with_query_fallback, and it simplifies repeated items_path option construction in response path labeling.

Changes:

  • Add focused unit tests validating arg-vs-query repo-scope resolution behavior for extract_repo_scope_with_query_fallback.
  • Refactor items_path construction in label_response_paths to use then_some(...) instead of repeated if/else blocks.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/response_paths.rs Replaces repeated items_path empty-check branching with then_some to reduce duplication while preserving behavior.
guards/github-guard/rust-guard/src/labels/helpers.rs Adds direct unit tests for repo-scope resolution logic used by issue/PR collection labeling.

Copilot's findings

Tip

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

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

Comment thread guards/github-guard/rust-guard/src/labels/helpers.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox

lpcox commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/27286598735/job/80595428791?pr=7274

Fixed in c7d4cd1. The CI failure was caused by network-dependent integration tests; the large payload tests now use local HTTP mock backends, and the Playwright image test skips on Docker registry timeout errors.

Copilot finished work on behalf of lpcox June 10, 2026 17:32
@lpcox lpcox merged commit c2c680e into main Jun 10, 2026
26 checks passed
@lpcox lpcox deleted the copilot/rust-guard-add-unit-tests branch June 10, 2026 17:34
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: Direct tests for extract_repo_scope_with_query_fallback + idiomatic then_some in response_paths.rs

3 participants