Skip to content

fix: searchFiles ReferenceError on stdout?.trim()#437

Merged
avoidwork merged 4 commits into
mainfrom
feat/fix-searchfiles-stdout-handling
Jun 23, 2026
Merged

fix: searchFiles ReferenceError on stdout?.trim()#437
avoidwork merged 4 commits into
mainfrom
feat/fix-searchfiles-stdout-handling

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

Description

Fix a bug in the searchFiles tool where unsafe optional chaining on stdout?.trim() causes a ReferenceError/TypeError when stdout is undefined. The fix replaces the pattern with const output = (stdout ?? "").trim(); to ensure output is always a string before calling split().

Type of Change

  • Bugfix (non-breaking change which fixes an issue)

Testing

  • The fix handles undefined, null, and empty string cases for stdout
  • Existing tests should continue to pass (no behavioral changes for valid inputs)
  • The empty string case is already handled by the existing if (!output) check

Coverage

  • 100% line coverage maintained

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

- Replace unsafe optional chaining with nullish coalescing fallback
- Ensures output is always a string before calling split()
- Handles undefined, null, and empty string cases for stdout
@avoidwork avoidwork self-assigned this Jun 23, 2026
@avoidwork

Copy link
Copy Markdown
Owner Author

Audit Results: fix-searchfiles-stdout-handling (Implementation)

Iteration 1

Goal Fulfillment

  • [PASS] Goal 1 (Fix stdout handling) — Implementation replaces stdout?.trim() ?? stdout with (stdout ?? "").trim() in src/tools/filesystem.js line 436

Spec Compliance

  • [PASS] Code matches spec requirement: "searchFiles must handle undefined stdout safely"
  • [PASS] All scenarios covered: undefined, null, and valid string stdout cases

Task Completion

  • [PASS] Task 1.1: Code fix applied
  • [PASS] Task 1.2: Edge cases verified (undefined, null, empty string all handled)
  • [PASS] Task 1.3: Tests pass (1176 pass, 0 fail, 1 skipped)
  • [PASS] Task 1.4: Lint passes (0 warnings, 0 errors)

Quality Check

  • [PASS] Minimal, surgical fix — no behavioral changes for valid inputs
  • [PASS] No forbidden patterns introduced
  • [PASS] No regressions detected

Result

No errors found. Proceeding to Step 10: Archive the OpenSpec change.

@avoidwork avoidwork enabled auto-merge (squash) June 23, 2026 12:09
@avoidwork avoidwork merged commit b83fd01 into main Jun 23, 2026
2 checks passed
@avoidwork avoidwork deleted the feat/fix-searchfiles-stdout-handling branch June 23, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant