Skip to content

fix(cli): a bad input path is a message, not a traceback - #3

Merged
hchittanuru3 merged 1 commit into
mainfrom
fix/cli-input-errors
Aug 14, 2026
Merged

fix(cli): a bad input path is a message, not a traceback#3
hchittanuru3 merged 1 commit into
mainfrom
fix/cli-input-errors

Conversation

@hchittanuru3

Copy link
Copy Markdown
Contributor

Found by installing postflight from PyPI into a clean venv and using it the way someone encountering it for the first time would.

Two ordinary mistakes produced full stack traces:

$ python -m postflight --otel /tmp/typo.jsonl
Traceback (most recent call last):
  ...
  File ".../adapters/otel.py", line 206, in turns_from_jsonl
    with open(path, encoding="utf-8") as handle:
FileNotFoundError: ...

$ python -m postflight --otel notes.txt
  ...
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Neither answers the question, and both tell the user the tool crashed, which is untrue. Now:

cannot read /tmp/typo.jsonl: No such file or directory
notes.txt is not newline-delimited JSON: Expecting value: line 1 column 1 (char 0) (expected one exported span object per line)

Both pinned by tests. The argparse error for a missing source and the Langfuse credentials check were already clean; these were the two paths that were not.

The rest of the fresh-install audit passed

  • Installs on 3.12 and 3.14 from both wheel and sdist, pulling zero dependencies (pip list shows only pip and postflight)
  • mypy --strict passes against the public API and catches a deliberate type error in it, which is the real test of py.typed: a missing marker would have made mypy skip the package silently
  • The README's Turn example, typed verbatim, produces the documented TOOL_REFUSAL + UNVERIFIED_CLAIM pairing
  • CLI, --coverage, and --json all behave, with exit 1 on a fault

Found while installing from PyPI into a clean environment and using it the way a
stranger would. Two ordinary mistakes both produced a full stack trace: a typo'd
filename raised FileNotFoundError out of turns_from_jsonl, and a file that is not
newline-delimited JSON raised JSONDecodeError from inside the parser.

A traceback answers neither question and tells the user the tool crashed, which is
untrue. Both are now SystemExit with a message that says what was wrong and, for the
JSONL case, what the file was supposed to contain.

Pinned. The argparse error for a missing source and the Langfuse credentials check were
already clean; these were the two paths that were not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hchittanuru3
hchittanuru3 merged commit f73765b into main Aug 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant