[Repo Assist] refactor(rust-guard): dedup owner/repo split logic, use label constants in tests - #10866
Conversation
…ts in tests Closes #10820 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Deduplicates repository identifier parsing in Rust guard labeling and aligns tests with canonical label constants.
Changes:
- Reuses
split_repo_idfor reaction and collaborator-permission checks. - Uses shared private-label constants in response-item tests.
Show a summary per file
| File | Description |
|---|---|
helpers.rs |
Centralizes validated owner/repository parsing. |
response_items.rs |
Uses canonical constants in private-label assertions. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Full ReportPart A — MCP reads: All 4 tools succeeded via Part B — MCP writes: All 7 write tools returned gateway MCP error Part C — CLI reads: Part D — CLI REST writes: Part E — GraphQL mutations: Same auth block; all 3 mutations rejected. No mutation succeeded. References: §31258661614
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Notes:
References: §31258661593
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Implements the two improvements suggested in #10820 ("Rust Guard: Dedup owner/repo split logic and align private-label constants in tests").
Changes
guards/github-guard/rust-guard/src/labels/helpers.rshas_maintainer_reaction_with_callbackandelevate_via_collaborator_permissionboth contained an inline "splitrepo_full_nameon/, validate both halves non-empty" block, duplicating the existing private helpersplit_repo_id. Both call sites now reusesplit_repo_idinstead of re-implementing the check.split_repo_idadditionally rejects arepohalf containing an extra/(e.g."org/foo/bar"), so both call sites now share the same (slightly stricter) validation instead of the previous inline version being weaker.guards/github-guard/rust-guard/src/labels/response_items.rssearch_repositories_private_repo_gets_private_labelhardcoded the raw literals"private"/"private:"instead of referencing the existinglabel_constants::PRIVATE_BASE/PRIVATE_PREFIXconstants used elsewhere in the module. Updated the test to use the shared constants so a future rename is caught at compile time instead of silently passing against stale literals.label_constantsimport into the#[cfg(test)]module (it's only used by tests) to avoid an unused-import warning in non-test builds.No behavior changes are intended for production code paths other than the (already-latent, stricter) extra-slash rejection noted above, which affects only malformed
owner/repostrings.Test Status
✅
cargo buildandcargo testfor the Rust guard pass locally: 628 passed; 0 failed.go1.26.4) required by the rootgo.modcould not be downloaded in this sandbox (proxy.golang.orgis blocked by the firewall), somake agent-finished(which also runs the Go test suite) could not be executed end-to-end. This PR touches only the Rust guard crate (guards/github-guard/rust-guard), which is independently built/tested viacargo, and does not touch any Go code, so Go test results are expected to be unaffected. Maintainers should confirm CI passes after push.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run