fix: enable --debug for all CLI commands with enhanced debug output#249
Merged
fix: enable --debug for all CLI commands with enhanced debug output#249
Conversation
3a04b54 to
c5048c9
Compare
Previously --debug was silently ignored by every command except sync. This wires the debug callback through all 39 command files and enhances debug output with full request/response logging similar to Apache libcloud. New debug modes: - --debug: verbose request/response (headers, body truncated to 2048 chars) - --debug-full: like --debug but no body truncation - --debug-curl: print reproducible curl commands (uses shlex.quote for safe shell escaping). Can be combined with --debug for both outputs. All debug output goes to stderr. Sensitive headers (Authorization, X-Api-Key, Cookie) are masked in verbose output. Curl commands include real token values for direct copy-paste reproducibility. Includes 66 new tests covering header masking, shell escaping, curl command generation, mode interactions, body truncation, and shell injection safety. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 119 tests verifying every CLI command correctly propagates --debug, --debug-full, and --debug-curl flags to the Client constructor. Tests include source-level AST inspection to catch future regressions, CLI integration via CliRunner for representative commands, flag combination tests, position flexibility tests, and hive shortcut coverage. Also fix test_curl_output_is_parseable_by_shlex which broke after the JWT cache feature added init-time debug messages to the log. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c5048c9 to
f84ae9d
Compare
maximelb
approved these changes
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
Previously,
--debugonly worked for thesynccommand. This PR fixes--debugto work across all 39+ CLI commands by wiring the debug parameters (print_debug_fn,debug_full_response,debug_curl,debug_verbose) through every command module's_get_org/_get_clienthelper.Additionally, the Client now provides three debug output modes:
--debug- verbose request/response logging to stderr (headers + truncated body)--debug-full- like--debugbut does not truncate response bodies--debug-curl- prints reproducible curl commands for each requestAll modes can be combined. Sensitive headers (Authorization, X-Api-Key, Cookie) are masked in verbose output. Curl output uses
shlex.quote()for shell safety.Sample debug output
Large responses are automatically truncated (default 2048 chars). Use
--debug-fullto see the complete body:Blast radius / isolation
limacharlie/commands/- each had a one-line change to pass 4 debug kwargs toClient(). TheClientclass inclient.pygained 3 new methods (_debug_request,_debug_response,_debug_curl_cmd) and header masking logic.--debugis not passed,print_debug_fn=Noneand all debug methods are no-ops.Performance characteristics
Zero overhead when debug flags are not set - all debug methods early-return when
_debug_fn is None. When active, the only cost is string formatting and stderr writes per HTTP request.Notable contracts / APIs
No changes to wire formats, API contracts, or data schemas. The
Client.__init__signature gains 3 new optional kwargs (debug_full_response,debug_curl,debug_verbose) - all with backwards-compatible defaults.Test plan
test_debug_flag_integration.py:Client()calls missing debug paramstest_debug_logging.pyfor Client-level debug methods🤖 Generated with Claude Code