fix: print the verbose traceback to stderr - #8
Open
blaipr wants to merge 1 commit into
Open
Conversation
The stream was passed to print as a value rather than as its `file`, so the traceback for an API error under -v was written to stdout, with a repr of the stderr object appended to it as a second value. stdout is where the requested document goes, so `-f json` and `-f yaml` came back unparseable to anything downstream the moment the server answered with an error. The generic handler below this one already routes to stderr; only this branch did not.
This was referenced Aug 18, 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.
Summary
ascenderkit/cli/__init__.pyprinted the traceback for an API error like this:The stream is passed as a value rather than as
file, so two things go wrong at once: the traceback lands on stdout, and a repr of the stderr object is appended to it as a second value.stdout is where the requested document goes. Driving
run()with aBadRequestunder-v -f json, this is what a caller receives on stdout today:stderr is empty, and
json.loadson that stream raises. Anyascender ... -v -f json | jqpipeline breaks the moment the server answers with an error. The genericexcept Exceptionhandler four lines below already writes to stderr, so this was the only branch out of step.The test passes the stream in rather than relying on a capture fixture, because the default for that parameter is bound to
sys.stderrwhen the module is imported, which is not the objectcapsysorcapfdinstalls for the duration of a test. It fails on the current code and passes on the fix.Type of Change
Component
CLI (
ascenderkit/cli/__init__.py), error handling.Checklist
pytest tests/unit): 352 passedblack --check ascenderkit tests setup.py,flake8 ascenderkit)Unreleased