[Repo Assist] Rust Guard: consolidate remaining split_once('/') call sites to use split_repo_id() - #11555
Conversation
… test constant literals Closes #11542 🤖 Generated by Repo Assist, an automated AI assistant. Root cause: labels/helpers.rs defines split_repo_id() which validates "owner/repo" strings (rejecting empty owner/repo or an extra '/'), but four call sites still used raw repo_id.split_once('/') and skipped this validation. Also, three tests in labels/mod.rs used raw string literals ("get_issue", "get_pull_request") instead of the existing tool_names constants. Fix: replaced the four raw split_once('/') call sites in repo_visibility_secrecy_for_repo_id, repo_visibility_private_for_repo_id, extract_repo_info_from_search_query, and the commit-integrity owner-authored-commit check with split_repo_id(), matching the pattern used elsewhere in the file. Replaced the three raw tool-name literals in tests with tool_names::GET_ISSUE / tool_names::GET_PULL_REQUEST. Trade-offs: split_repo_id additionally rejects ids with an extra '/' in the repo segment (e.g. "owner/repo/extra"), tightening validation slightly; this should not change behavior for well-formed owner/repo strings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Consolidates repository ID parsing through split_repo_id() for consistent malformed-input rejection.
Changes:
- Replaces four unvalidated repository ID splits.
- Uses canonical tool-name constants in tests.
- Tightens handling of extra-slash repository IDs.
Show a summary per file
| File | Description |
|---|---|
labels/helpers.rs |
Centralizes repository ID validation. |
labels/mod.rs |
Replaces test literals with constants. |
Review details
💡 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: 1
- Review effort level: Balanced
| let repo_id = format_repo_id(&owner, &repo); | ||
| return (owner, repo, repo_id); | ||
| } | ||
| if let Some((owner, repo)) = split_repo_id(repo_ref) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback and fix failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/32372018072/job/96492964171?pr=11555 |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Added regression coverage for malformed repository IDs ( |
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write succeeded. No FAIL condition triggered.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked through any surface. The INCONCLUSIVE rating reflects methodology gaps (absent write tools, unauthenticated Run: §32397187134
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes succeeded. Zero FAIL conditions observed. References: §32397187082
|
🤖 This PR was created automatically by Repo Assist, an AI assistant.
Closes #11542
Root cause
labels/helpers.rsdefines a private helpersplit_repo_id()that splits"owner/repo"and rejects malformed input (empty owner/repo, or an extra/). It's already used at several call sites, but four sites still performed a raw, unvalidatedrepo_id.split_once('/'):repo_visibility_secrecy_for_repo_idrepo_visibility_private_for_repo_idextract_repo_info_from_search_queryBecause raw
split_once('/')happily returns things like("owner", "")for malformed input whilesplit_repo_idreturnsNone, these four sites behaved slightly differently (and less safely) than the rest of the codebase.Additionally, three tests in
labels/mod.rsused raw string literals ("get_issue","get_pull_request") instead of the existingtool_namesconstants meant to prevent typos/drift between production code and tests.Fix
.split_once('/')call sites withsplit_repo_id(...), matching the pattern already used elsewhere in the file. Inextract_repo_info_from_search_query, the now-redundant!owner.is_empty() && !repo.is_empty()check was removed sincesplit_repo_idalready guarantees non-empty owner/repo.tool_names::GET_ISSUE/tool_names::GET_PULL_REQUEST.Trade-offs
split_repo_idadditionally rejects ids with an extra/in the repo segment (e.g."owner/repo/extra"), tightening validation slightly. This should not change behavior for any well-formedowner/repostring seen in practice.Test Status
cargo buildsucceedscargo test— all 642 tests pass, 0 failedcargo fmt --check— no new formatting diffs introduced by this change (pre-existing unrelated diffs inmod.rsuntouched)Add this agentic workflow to your repo
To install this agentic workflow, run