test(claude_code): reject empty stdin_input symmetric to prompt

run_claude validated empty prompt strings but silently accepted
stdin_input="", letting an empty stdin reach the subprocess and surface
as a confusing CLI failure instead of a clear ValueError.
This commit is contained in:
mateo-berri 2026-05-17 06:13:48 +00:00
parent 0901890994
commit 9a4eb2dea5
No known key found for this signature in database
2 changed files with 11 additions and 0 deletions

View file

@ -301,6 +301,15 @@ def test_run_claude_validates_required_params():
api_key="k",
runner=runner,
)
with pytest.raises(ValueError, match="stdin_input"):
run_claude(
prompt=None,
stdin_input="",
model="m",
base_url="http://x",
api_key="k",
runner=runner,
)
with pytest.raises(ValueError, match="model"):
run_claude(
prompt="hi",

View file

@ -125,6 +125,8 @@ def run_claude(
raise ValueError("must supply only one of `prompt` or `stdin_input`, not both")
if prompt is not None and not prompt:
raise ValueError("prompt must be a non-empty string when provided")
if stdin_input is not None and not stdin_input:
raise ValueError("stdin_input must be a non-empty string when provided")
if not model:
raise ValueError("model must be a non-empty string")
if not base_url: