You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unhandled exceptions break the --json contract #25
--json is supposed to emit exactly one {"ok": ...} line. run_remote() depends on it — it parses the remote's stdout and reports unexpected output when parsing fails. The whole remote path rests on this.
main() catches only CcPeerError and KeyboardInterrupt. Anything else escapes as a traceback: stdout stays empty, stderr gets a multi-line dump, and run_remote folds that entire dump into a single error string. Neither a human nor a parser can read the result.
Three reachable paths
discover() doesn't guard the directory walk. Individual files are wrapped in (OSError, ValueError), but directory.glob("*.json") isn't. is_dir() passing doesn't mean readable — a sudo'd run under a different uid, or NFS permissions, raises PermissionError straight through.
Binary on stdin.cat some.png | cc-peer send --to x - → UnicodeDecodeError.
Missing message argument hangs.cc-peer send --to X with no message and a TTY falls into sys.stdin.read() and waits with no prompt. Ctrl-D produces an empty string and only then the "refusing to send an empty message" error. An agent running this through a Bash tool hangs until its timeout — the worst version, since nothing indicates what it's waiting for.
Fix
except Exception fallback in main() that still emits JSON under --json
Wrap the glob in discover()
Detect sys.stdin.isatty() with no message argument and fail immediately with a usage hint
Acceptance criteria
Every failure path emits parseable JSON under --json
An unreadable sessions directory reports rather than tracebacks
Binary stdin reports rather than tracebacks
send --to X with no message and a TTY exits at once
Tests cover the exit codes and the JSON shape on failure — main(argv) is already injectable
Activity