Fix/logs help default command#3252
Conversation
Greptile SummaryFixes
Confidence Score: 5/5Safe to merge — the change is a self-contained fix inside the existing parse_args compatibility shim with no impact on log retrieval, datastore, or any other command path. The fix correctly re-raises click.exceptions.Exit so Click's own help machinery is never swallowed, and returns early on a successful first parse to avoid the previous double-parse on every normal invocation. All three backward-compat paths (help, explicit subcommand, bare pathspec/option forwarding) are exercised by the new tests. No files require special attention. Important Files Changed
Reviews (5): Last reviewed commit: "test: use pytest-mock for logs CLI routi..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3252 +/- ##
=========================================
Coverage ? 29.99%
=========================================
Files ? 381
Lines ? 52467
Branches ? 9260
=========================================
Hits ? 15735
Misses ? 35584
Partials ? 1148 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
86b42ec to
0eb1e3c
Compare
1e1b0cc to
3e7e139
Compare
PR Type
Summary
Fix
logs --helpso it shows only thelogsgroup help instead of also falling through to the defaultlogs showcommand help.Issue
Fixes #3251
Reproduction
Runtime: local
Commands to run:
Where evidence shows up: parent console
Before (error / log snippet)
After (evidence that fix works)
Root Cause
logs uses a custom CustomGroup to preserve backward compatibility for legacy invocations such as logs , treating them as logs show .
The fallback logic in CustomGroup.parse_args() was too broad. It first attempted to parse the provided args, and if parsing consumed the argument list or failed, it retried with the default command inserted. Group-level help is handled by Click during parsing, so logs --help could be treated like a fallback case and append logs show --help output after the group help.
Why This Fix Is Correct
The fix handles group-level help before default-command fallback. This restores the expected Click invariant:
logs --help shows group help.
logs show --help shows subcommand help.
logs still routes to the default show command.
The change is minimal because it stays inside the existing CustomGroup.parse_args() compatibility layer and does not change datastore, log loading, or command behavior outside argument parsing.
Failure Modes Considered
The fix handles group-level help before default-command fallback. This restores the expected Click invariant:
logs --help shows group help.
logs show --help shows subcommand help.
logs still routes to the default show command.
Tests
Non-Goals
This PR does not change log retrieval, log scrubbing, datastore behavior, or the existing default-command design for logs.
AI Tool Usage
GPT-5.5
AI tools were used to inspect the relevant CLI code, propose the minimal parser fix, and draft tests. I reviewed the generated changes and verified them locally with focused unit tests and manual CLI checks.