Skip to content

fix(shell): gh repo names and API routes are not file paths - #5751

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/fix-gh-slug-paths
Oct 26, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/fix-gh-slug-paths

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Every read-only gh query on a repo asked for approval again, with a false "Reads or changes files outside this project: …\amd\gaia" warning and no "always" option. The path check joined the --repo value and the gh api endpoint onto the working folder. Those two positions now skip the path check. Every other gh operand is still checked, including --body-file and gh api --input, which read local files.

Closes #5737

Test plan

  • python -m pytest tests/unit/test_shell_pipeline_segments.py -k gh_
  • In the Agent UI in Ask mode, ask "how many open issues does amd/gaia have?". The gh prompt has no outside-project warning, and approving gh api repos/amd/gaia … doesn't re-ask with a confirm-once prompt on each retry.

Every read-only gh query on a repo asked for approval again, with a false
"Reads or changes files outside this project: ...\amd\gaia" warning and no
"always" option: the path check joined the --repo value and the gh api
endpoint onto the working folder. Those two positions now skip the path
check. Every other gh operand is still checked, including --body-file and
gh api --input, which read local files.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This stops read-only gh commands from tripping the "outside this project" warning. A repo name like amd/gaia or an API route like repos/amd/gaia was being read as a folder next to the working directory. The fix is narrow and errs on the safe side. Only the --repo value and the gh api endpoint skip the path check. Flags that really read local files (--body-file, --input) are still checked, and tests cover both directions.

Nothing blocks the merge. The one gap: the PR shows no live run of the permission prompt it fixes. The Agent UI step in the test plan is still unchecked, so the claim that the confirm-once re-ask is gone hasn't been shown.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on reading the code alone. I couldn't run the unit tests here because the runner has no pytest, so the green checks come from CI, not from this review.

🔍 Technical details

🟡 Important

  • No surface evidence for a user-visible prompt change. The fix changes what the Agent UI tool-approval prompt shows. Per the rubric, attach the Agent UI run from the test plan: a before/after screenshot of the gh approval with no outside-project warning, and a retry that isn't re-asked. At minimum, add the route/CLI-level output. The unit tests gate the logic, not the prompt.

🟢 Minor

  • Attached short form isn't recognised (src/gaia/agents/tools/shell_tools.py _gh_remote_positions). pflag also accepts -Ramd/gaia, which still falls through to the path check and prompts. This is safe, just an inconsistent result next to -R=amd/gaia. If you want parity, add a token.startswith("-R") and len(token) > 2 branch.
  • Weak assertion in the negative test (tests/unit/test_shell_pipeline_segments.py, test_gh_flags_that_read_local_files_are_still_checked). refusal is not None or any(...) passes when either holds, so it can't tell which path caught the file. Consider asserting the specific outcome you expect from cwd=work (the ../secret.txt entry in outside).
  • The endpoint skip only fires when api is argv[1]. gh -R x api ../foo still checks ../foo. That's conservative and fine, but a one-line test pinning it would stop a later "fix" from widening the skip.

Strengths

  • The skip is opt-in by position, not by pattern, so a stray ../ anywhere else in a gh command is still scanned.
  • _GH_API_VALUE_FLAGS matches gh api's value-taking flags, so -X GET repos/... and --jq ... resolve the endpoint correctly. --input is consumed as a value but deliberately left checked.
  • The regression test reproduces the real failure: the project folder differs from the cwd, so amd/gaia would have resolved outside the project.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Addressed:

  • pflag's attached -Ramd/gaia is now skipped like -R=amd/gaia and --repo=amd/gaia.
  • The local-file test asserts the exact outcome: no refusal, and outside == ["secret.txt"] (or ["body.json"]).
  • New test: gh -R x/y api ../foo still checks ../foo, since only gh api <endpoint> skips.

Evidence. This test reproduces the real failure, where the command's folder is outside the chat's allowed folders. Without the fix, the path check records …\elsewhere\amd\gaia as outside, the same false note the rc11 Agent UI showed: "Reads or changes files outside this project: …\third-party-issues-audit-e2af4c\amd\gaia." With it, nothing is recorded:

with fix   : (None, [])
fix removed: ['C:\Users\Kalin\AppData\Local\Temp\tmpj4varho2\else\amd\gaia']

In the rc11 Agent UI the one question "how many open issues does amd/gaia have?" produced three confirm-once prompts (gh issue list --repo amd/gaia …, then gh api repos/amd/gaia … twice), each carrying that warning.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 26, 2026
Merged via the queue into amd:main with commit c17ea45 Oct 26, 2026
32 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/fix-gh-slug-paths branch October 26, 2026 09:58
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 26, 2026
5 of 9 tasks
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 26, 2026
## Why this matters

v0.25.2 is a bug-fix release on top of v0.25.1: setup and install no
longer stop at the first failed step, shell and file access handle
Windows paths and text encodings, the Agent UI and desktop app stop
showing misleading states, and document search, email and skills each
lose a handful of rough edges. 55 commits since v0.25.1; notes are in
`docs/releases/v0.25.2.mdx` and credit 15 outside contributors.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.25.2.mdx
--tag v0.25.2` passes
- [x] `mintlify validate` (from `docs/`) passes
- [x] `python util/check_doc_links.py --internal-only`, `python
util/check_doc_versions.py` and `node
installer/version/bump-ui-version.mjs --check` pass
- [x] `python util/check_component_core_api.py --release-version 0.25.2`
passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
tests/unit/test_release_tag.py
tests/unit/test_hub_core_version_gate.py`: 156 passed
- [ ] CI green on the merge commit
- [ ] `release_train_dryrun.yml` passes on that commit before the RC tag

## Evals to re-run on the RC tag

LLM-affecting PRs merged without per-PR evals; run these on
`v0.25.2-rc1`:

- `gaia_shell` and shell/safety (amd#5794, amd#5751, amd#5768)
- `gaia_honesty` (amd#5753)
- `gaia_skills_tasks` and `gaia_skills_lifecycle` (amd#5422, amd#5755)
- `rag_retrieval` and `rag_quality` (amd#5742, amd#5754, amd#5761, amd#5817, amd#5812)
- email scenarios (amd#5767, amd#5811)
- `tool_selection` and `error_recovery` (amd#5732)
- Claude provider thinking replay (amd#5072)
- memory categories (amd#5818 merged; amd#5756 has not)

## Release checklist

- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.25.2-rc1`
- [ ] Extend the changelog if main gains commits before the tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(shell): gh repo names are read as file paths, so every read-only gh query re-prompts with a false outside-project warning

2 participants