test(agents): capture shell tool raw ValueError crash on NUL-byte command bug (#181) #199
No reviewers
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
cleveragents/cleveractors-core!199
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdd/m1-shell-nul-byte-command"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds the mandatory TDD issue-capture test for #181 ("
ToolAgent._execute_shell_commandlets acommandstring containing an embedded NUL byte reach the unguardedasyncio.create_subprocess_shell()call, which raises a rawValueErrorinstead of the tool's ownExecutionError").ToolAgent._execute_shell_command(src/cleveractors/agents/tool.py) only runs_enforce_safe_mode_blocklistbefore buildingcmd_strand callingasyncio.create_subprocess_shell(cmd_str, ...). CPython's subprocess machinery raises a rawValueError("embedded null byte") for any command string containing a NUL byte, before the system shell is ever invoked. The surroundingtry/exceptonly catchesasyncio.TimeoutError, so thatValueErrorpropagates uncaught out of_execute_shell_command,_shell_tool, andToolAgent.invoke()— unlikeprocess_message(), whose genericexcept Exceptionalready re-wraps any such crash as anExecutionError,invoke()(the graph tool-node dispatch entry point) has no catch-all.This PR extends the existing
features/tool_agent.feature/features/steps/tool_agent_steps.pypair (rather than adding a new feature/step file, per the project's step-file rules) with a new scenario tagged@tdd_issue @tdd_issue_181 @tdd_expected_fail:ToolAgentwithallow_shell: trueandsafe_modeleft at its default (true).ToolAgent.invoke("shell", {"command": ...})directly with acommandcontaining an embedded NUL byte.ExecutionError, not aValueError.The NUL byte never reaches a real shell process — CPython's own subprocess machinery rejects it at the Python/OS exec-argument layer before
create_subprocess_shellspawns anything.Verified locally that the assertion genuinely fails against current
develop(invoke()raises a bareValueError: embedded null byteinstead ofExecutionError), confirming the bug is reproduced; the failing step raises onlyAssertionError, so the TDD CI hook inverts it correctly and the scenario passes CI with the tag in place.The actual fix (rejecting an embedded NUL byte in
_execute_shell_commandbeforeasyncio.create_subprocess_shellis reached) lands separately onbugfix/m1-shell-nul-byte-commandper issue #181, once this TDD PR is merged.Note: per existing project practice (see PR !192), this repository's PRs target
develop, notmasteras issue #183's Definition of Done states.Closes #183
Test plan
nox -s lint— greennox -s format -- --check— greennox -s typecheck— green (0 errors)nox -s security_scan— green (bandit + semgrep, 0 findings)nox -s dead_code— green (vulture, 0 findings)nox -s unit_tests— green (160 features, 3374 scenarios, 15539 steps, including the new TDD scenario passing via@tdd_expected_failinversion)nox -s integration_tests— green (382/382 Robot Framework tests)nox -s coverage_report— 97.3% (>= 96.5% threshold)nox -s benchmark_regression -- --quick— green (no significant change)ValueError) when@tdd_expected_failis removed locally, proving the bug is genuinely reproduced🤖 Generated with Claude Code
test(agents): capture shell tool raw ValueError crash on NUL-byte command bug (#181)to test(agents): capture NUL-byte crashes in shell (#181) and file_read (#180) toolsfe0e6135b8df1c708ffbtest(agents): capture NUL-byte crashes in shell (#181) and file_read (#180) toolsto test(agents): capture shell tool raw ValueError crash on NUL-byte command bug (#181)PR Review: !199 (Ticket #183 / Bug #181)
Verdict: Approve
A clean, well-scoped TDD-capture PR that fully satisfies issue #183's acceptance criteria. I independently verified locally that the bug is genuinely reproduced and that all quality gates pass on the PR head.
Verification performed (local, authoritative)
tdd/m1-shell-nul-byte-command(df1c708) on top ofdevelop(6d2750e): single atomic commit, parent is develop tip, zero merge commits.Thenstep fails withExpected ExecutionError, but got ValueError: embedded null byte— i.e. the underlying assertion genuinely fails on unfixed code and is inverted by the@tdd_expected_failpolicy, exactly as the TDD workflow requires. The When step stores the exception incontext.error(raising onlyAssertionErrorinThen), so the inversion applies correctly.nox -s unit_tests(full suite): 161 features / 3375 scenarios / 15543 steps, all green.nox -s lint: green.nox -s typecheck: 0 errors (one pre-existing unrelated warning about the optionallangchain-anthropic-style import).nox -s coverage_report: 97.3% (>= 96.5% configured threshold).Correctness analysis
invoke()→_execute_tool→builtin_tools["shell"]→_shell_tool→_execute_shell_command, whosetryaroundcreate_subprocess_shellonly catchesasyncio.TimeoutError; the rawValueErrorescapes to the caller. The scenario drives exactly this path.fork, so no shell process is ever spawned — the test is safe by construction, as claimed."echo abc\x00def"contains none of the safe-mode blocklisted substrings (rm,del,format,shutdown,reboot,kill), so the blocklist cannot make the scenario pass for the wrong reason. Good detail.TddExpectedFailPolicy.on_scenariowill flag the stale tag — the intended removal trigger works for this scenario.TimeoutPolicy.resolve()already raisesExecutionErrorfor malformedtimeoutargs, and theValueErrorinTimeoutPolicy.__init__is pre-validated at construction — no adjacent latent issue to flag here.process_message()path, valid-command regression) belong to the fix PR, deliberately deferred per the TDD workflow — not gaps in this PR.Critical Issues
None
Major Issues
None
Minor Issues
None
Nits
features/steps/tool_agent_steps.py:292— the suppression comment reads# pylint: disable=broad-except, but every other occurrence infeatures/(10+) uses the house spelling# pylint: disable=broad-exception-caught. Comment-only and inert (the project lints with ruff, not pylint), but worth aligning for consistency. Non-blocking.Scope exclusions (per author's notes / reviewer policy)
developrather than the DoD'smaster: established repository practice (per PR !192), already noted in the PR description — not re-raised.bugfix/m1-shell-nul-byte-commandis the TDD process working as designed, not a deficiency.Summary
An exemplary TDD-capture PR: precise scope matching issue #183, safe-by-design reproduction, meaningful (non-tautological) assertions, correct tag lifecycle, honest and detailed PR description, and all quality gates independently verified green. The single nit is a comment-spelling inconsistency. Recommend merging; the fix should then land on
bugfix/m1-shell-nul-byte-commandper #181.🤖 Reviewed as GLM 5.3 Flash (bifrost/glm-5.3-flash), acting for @hurui200320.
df1c708ffb84c7f89b5f