Skip to content

Commit c65506c

Browse files
jwesleyeclaude
andcommitted
0.3.1: catch ValueError in CLI main so size-limit errors render cleanly
Oversized title/body on `send` or `reply` raised an uncaught ValueError from `_validate_lengths`, printing a full Python traceback instead of a friendly "error: body exceeds 1400 chars (N)" message. `main()` now catches ValueError alongside RuntimeError. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f140d3b commit c65506c

7 files changed

Lines changed: 35 additions & 6 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
},
66
"metadata": {
77
"description": "Asynchronous 1-to-1 postcard messaging between AI agent sessions via a Git-backed ledger",
8-
"version": "0.3.0"
8+
"version": "0.3.1"
99
},
1010
"plugins": [
1111
{
1212
"name": "postcard",
1313
"source": "./",
1414
"description": "Postcard protocol for cross-session AI agent messaging. Ships a CLI, slash commands, a model-invoked skill, a Clerk subagent for inbox triage, and SessionStart / Stop / UserPromptSubmit hooks.",
15-
"version": "0.3.0",
15+
"version": "0.3.1",
1616
"license": "MIT",
1717
"repository": "https://github.com/Open-Agent-Tools/Postcard",
1818
"keywords": ["messaging", "agents", "ledger", "git", "async", "multi-agent"]

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcard",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Asynchronous 1-to-1 postcard messaging between AI agent sessions via a Git-backed ledger.",
55
"author": {
66
"name": "Open Agent Tools"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to oat-postcard. Dates are UTC.
44

5+
## [0.3.1] - 2026-04-22
6+
7+
### Fixed
8+
- CLI no longer crashes with a Python traceback when `send` or `reply`
9+
is called with an oversized title (>140) or body (>1400). The
10+
underlying `ValueError` is now caught by `main()` and rendered as a
11+
clean `error: body exceeds 1400 chars (1823)` message with exit
12+
code 1. Same fix covers any other `ValueError` that bubbles up from
13+
CLI commands.
14+
515
## [0.3.0] - 2026-04-22
616

717
### Added

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "oat-postcard"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
description = "Asynchronous 1-to-1 postcard messaging between AI agent sessions via a Git-backed ledger."
55
readme = "README.md"
66
license = { text = "MIT" }

src/oat_postcard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.0"
1+
__version__ = "0.3.1"

src/oat_postcard/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def main(argv: list[str] | None = None) -> int:
442442
args = build_parser().parse_args(argv)
443443
try:
444444
return args.func(args)
445-
except RuntimeError as e:
445+
except (RuntimeError, ValueError) as e:
446446
print(f"error: {e}", file=sys.stderr)
447447
return 1
448448

tests/test_cli.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,22 @@ def test_log_rejects_bad_time_spec(tmp_root, session_env, capsys):
111111
rc = cli.main(["log", "--since", "not a real duration"])
112112
assert rc == 2
113113
assert "invalid time spec" in capsys.readouterr().err
114+
115+
116+
def test_send_oversized_body_returns_clean_error(tmp_root, session_env, capsys):
117+
session.init_session()
118+
big = "x" * (ledger.BODY_MAX + 1)
119+
rc = cli.main(["send", "peer", "short title", big])
120+
assert rc == 1
121+
err = capsys.readouterr().err
122+
assert "body exceeds" in err
123+
assert "Traceback" not in err
124+
125+
126+
def test_send_oversized_title_returns_clean_error(tmp_root, session_env, capsys):
127+
session.init_session()
128+
rc = cli.main(["send", "peer", "x" * (ledger.TITLE_MAX + 1), "body"])
129+
assert rc == 1
130+
err = capsys.readouterr().err
131+
assert "title exceeds" in err
132+
assert "Traceback" not in err

0 commit comments

Comments
 (0)