test(agents): capture file_read raw ValueError crash on NUL-byte path bug (#180) #200
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.
Dependencies
No dependencies set.
Reference
cleveragents/cleveractors-core!200
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdd/m1-file-read-nul-byte-path"
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
Was meant to add the mandatory TDD issue-capture test for #180 ("
file_readtool crashes with a rawValueErrorinstead of a descriptiveExecutionErrorwhen the path contains an embedded NUL byte"), per the companion TDD ticket #182.Investigation found this bug does not reproduce against current code. Commit
fe9ce14(the fix for sibling issue #175,file_write's path validation) already added a shared_validate_path_characters()helper and explicitly applied it to_file_read_tooltoo, ahead of every branch that can reach the filesystem (src/cleveractors/agents/tool.py:1016). Its_ILLEGAL_PATH_CHARSset includes every ASCII control character0x00-0x1F, so a NUL byte is already rejected with a descriptiveExecutionErrorbeforeos.path.realpath()— the crash site #180 names — is ever reached. Confirmed directly against current code:Issues #175 and #180 were filed as distinct tickets (per the project's one-concern-per-issue rule) before #175's fix landed with broader scope than its own ticket described — #180 and this PR just weren't cross-referenced against it.
Because there's no live bug to invert, this PR adds a plain regression-guard scenario to
features/tool_agent.feature/features/steps/tool_agent_steps.py(extending the existing pair, per the project's step-file rules) tagged only@tdd_issue @tdd_issue_180— no@tdd_expected_fail, since the assertion already passes outright and the project'sTddExpectedFailPolicyfails any@tdd_expected_failscenario whose assertion is never inverted (a "stale tag" signal). The scenario callsToolAgent.invoke("file_read", {"file": ...})directly with a relative NUL-byte path (so it exercises the exactsafe_mode/os.path.realpath()branch #180 named, rather than the unrelated absolute-path guard) and asserts anExecutionErrornaming "disallowed characters" is raised.Validity of the test was verified: the
_validate_path_characters()call was temporarily removed from_file_read_tool(simulating the pre-fe9ce14state) and the scenario re-run in isolation — it then fails withExpected ExecutionError, but got <class 'ValueError'>, reproducing issue #180's exact signature. The guard was restored immediately after;src/cleveractors/agents/tool.pycarries no diff in this PR.This PR does not close #180 or #182 — maintainer triage should confirm and close both, referencing
fe9ce14, since no separate bugfix PR is needed for #180.Note: per existing project practice (see PR !192), this repository's PRs target
develop, notmasteras issue #182's Definition of Done states.Refs #180, Refs #182
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— greennox -s coverage_report— green (>= 96.5% threshold)Expected ExecutionError, but got ValueError) when_validate_path_characters()is temporarily removed from_file_read_tool, proving the regression test actually guards the fix🤖 Generated with Claude Code
96ddb46e03abb0ed0888PR Review: !200 (Ticket #180, TDD companion #182)
Verdict: Approve
Test-only PR (+56/-0 across the existing
features/tool_agent.feature/features/steps/tool_agent_steps.pypair) adding a regression-guard scenario for thefile_readNUL-byte-path bug. The central claim — that the bug no longer reproduces becausefe9ce14(_validate_path_characters, from #175's fix) already guards_file_read_tool— was independently verified against the current code, and the new scenario was mutation-verified to actually guard the fix. All local quality gates that can be affected by this change are green. The one deviation from issue #182's letter (no@tdd_expected_failtag) is necessary, correct, and well documented:TddExpectedFailPolicy.on_scenario(features/tdd_expected_fail.py:105-117) fails any@tdd_expected_failscenario whose assertion passes without inversion, so tagging this already-passing scenario would break CI.Critical Issues
None.
Major Issues
None.
Minor Issues
None.
Nits
features/steps/tool_agent_steps.py, lines 277–289 (step docstring) — The docstring states the scenario "exercises the exact branch issue #180 names as the crash site (os.path.realpath()inside thesafe_modesymlink-escape check)" and then, one sentence later, correctly says_validate_path_characters"rejects the NUL byte before any of_file_read_tool's branches touch the filesystem." Strictly speaking, the scenario exercises the validation guard that protects the crash site — therealpathbranch itself is unreachable for NUL-byte input (that is the whole point of the guard). The same mild overstatement appears in the scenario's feature-file comment block. Recommendation: reword to "exercises the same entry path that would reach theos.path.realpath()crash site if the validation guard were absent." Non-blocking; behavior and tags are correct.features/steps/tool_agent_steps.py, line 296 vs line 317 — The two adjacent sibling NUL-byte steps use different (and inert) broad-except disable comments: the new step uses# pylint: disable=broad-exceptwhile the #181 sibling uses# pylint: disable=broad-exception-caught. Neither is enforced (the project lints with ruff E/F/W/B/I, which does not flag this), so this is purely cosmetic consistency between the paired steps. Consider aligning the wording in a future touch-up.Summary
Verification performed (local, authoritative):
abb0ed0, based squarely ondevelop@84c7f89, single commit, mergeable) and the full changed codebase context:src/cleveractors/agents/tool.py(_validate_path_characters,_ILLEGAL_PATH_CHARS,_file_read_tool,invoke/_execute_toolerror contract), the sibling #181 scenario/steps,features/tdd_expected_fail.py, and the tool docs.safe_mode=true, no_unsafe_mode, relative path),ToolAgent.invoke("file_read", {"file": "abc\x00def.txt"})raisesExecutionError: File path contains disallowed characters: '\x00'...— matching the scenario'stool execution should fail with message containing "disallowed characters"assertion, which also type-checks the error asExecutionError(i.e., the required "ExecutionError, not a raw ValueError" assertion from #182's acceptance criteria is satisfied via the shared Then step)._validate_path_characters(simulating the pre-fe9ce14state) with the same arguments reproduces issue #180's exact signature —ValueError: lstat: embedded null character in pathescapinginvoke()uncaught. The scenario would therefore catch a regression of the original bug. The PR author's identical verification claim is accurate.nox -s lint✅,nox -s format -- --check✅,nox -s typecheck✅ (0 errors),behave features/tool_agent.feature✅ (63/63 scenarios, incl. the new one, run in isolation via tag filter as well). Coverage is oversrconly and nosrcfiles changed, so the threshold is unaffected; commit message reports 97.3% vs the 96.5% threshold.fe9ce14exists with the quoted message; the_ILLEGAL_PATH_CHARS0x00–0x1F claim is accurate; the single-commit, no-fix-commit-per-branch rule is honored).Per reviewer instructions, the following author-decided / red-tape items are excluded from this review (the author explicitly decided or deferred them in the PR description and on #180): not closing #180/#182 from this PR (deferred to maintainer triage), targeting
developinstead of the DoD'smaster(established practice per PR !192), the missingISSUES CLOSEDfooter, and label/CHANGELOG housekeeping.Informational, non-gating: CI run 598 on the PR head shows
CI / benchmarkfailing with the other 9 jobs green. Per review policy CI is not relied on here; noting only that this feature-only change cannot affect ASV benchmark workloads (which exercisesrc//benchmarks/), so the failure appears unrelated to this diff.Note: GISM0 unavailable in this session — reviewed without the ticket memory journal, continuing from Gitea sources only.
Nice, disciplined piece of TDD-triage work: the investigation is correct, the guard is real, and the documentation of the deviation is exemplary. Approved — maintainer triage can now close #180/#182 referencing
fe9ce14.abb0ed08885e9ca51530