Observed Behavior
In GithubCLI.merged_pr_by_head(), any exception that occurs during gh pr list execution—including missing GitHub authentication (gh auth login), rate limits, network timeouts, or invalid repository arguments—is caught by a bare except Exception: pass. The method silently returns an empty list []. Consequently, commands like treefort prune report "No merged PR worktrees found to prune." without informing the user that GitHub communication failed.
Expected Behavior
GithubCLI.merged_pr_by_head() should log errors, warnings, or propagate appropriate diagnostic information so that authentication or network failures are transparent to the user and not disguised as "no merged PRs found".
Steps to Reproduce
- Log out of GitHub CLI (
gh auth logout) or disconnect network connectivity.
- In a project with existing worktrees, execute
treefort prune.
gh pr list exits with an error status (e.g. To get started with GitHub CLI, please run: gh auth login).
merged_pr_by_head catches CalledProcessError via except Exception: pass and returns [].
- Prune command reports:
"No merged PR worktrees found to prune." with zero warnings about authentication failure.
Minimal Reproduction Environment / Conditions
- Version / Branch / Commit:
release-v0.5.x@6d07c0c
- Component:
treefort.gh.GithubCLI.merged_pr_by_head
Errors, Logs & Telemetry
# src/treefort/gh.py:57-65
try:
with self.run(args) as p:
output = p.stdout
prs = json.loads(output)
if prs:
return prs
except Exception:
pass # Silently swallows CalledProcessError, json.JSONDecodeError, etc.
return []
Deliverables & Testing Requirements
- Log caught exceptions at
warning or error level with command output details.
- Guard against
None values when config.owner or config.name is missing to prevent passing --repo None/None.
- Regression Safety: Add a unit test in
tests/test_gh.py verifying that when self.run() raises an exception, the error is logged and handled appropriately.
Technical Pointers & Root Cause Clues
- Suspected Components:
src/treefort/gh.py:43-65 (merged_pr_by_head)
- Related Commits:
21941c3, bd7ed4c
Notes & Edge Cases
- When users run
treefort prune in CI or environments without GH tokens, they should immediately be alerted why PR queries are returning empty.
Metadata
Severity / Priority: P2 (Normal)
Area: bug, gh, prune
AI Usage
Drafted with Gemini following the DEEP framework based on code review findings against release-v0.5.x. Reproduction conditions and code references were verified in the codebase.
Observed Behavior
In
GithubCLI.merged_pr_by_head(), any exception that occurs duringgh pr listexecution—including missing GitHub authentication (gh auth login), rate limits, network timeouts, or invalid repository arguments—is caught by a bareexcept Exception: pass. The method silently returns an empty list[]. Consequently, commands liketreefort prunereport"No merged PR worktrees found to prune."without informing the user that GitHub communication failed.Expected Behavior
GithubCLI.merged_pr_by_head()should log errors, warnings, or propagate appropriate diagnostic information so that authentication or network failures are transparent to the user and not disguised as "no merged PRs found".Steps to Reproduce
gh auth logout) or disconnect network connectivity.treefort prune.gh pr listexits with an error status (e.g.To get started with GitHub CLI, please run: gh auth login).merged_pr_by_headcatchesCalledProcessErrorviaexcept Exception: passand returns[]."No merged PR worktrees found to prune."with zero warnings about authentication failure.Minimal Reproduction Environment / Conditions
release-v0.5.x@6d07c0ctreefort.gh.GithubCLI.merged_pr_by_headErrors, Logs & Telemetry
Deliverables & Testing Requirements
warningorerrorlevel with command output details.Nonevalues whenconfig.ownerorconfig.nameis missing to prevent passing--repo None/None.tests/test_gh.pyverifying that whenself.run()raises an exception, the error is logged and handled appropriately.Technical Pointers & Root Cause Clues
src/treefort/gh.py:43-65(merged_pr_by_head)21941c3,bd7ed4cNotes & Edge Cases
treefort prunein CI or environments without GH tokens, they should immediately be alerted why PR queries are returning empty.Metadata
Severity / Priority: P2 (Normal)
Area:
bug,gh,pruneAI Usage
Drafted with Gemini following the DEEP framework based on code review findings against
release-v0.5.x. Reproduction conditions and code references were verified in the codebase.