crewAIInc/crewAI · error · ValueError
action='search' requires 'path' and 'pattern'
Error message
action='search' requires 'path' and 'pattern'
What it means
action='search' in DaytonaFileTool._run requires 'path' (file or directory to scan) and 'pattern' (text/regex to look for); missing either raises ValueError before self._search runs. Unlike 'find' (filename globbing), search inspects file contents, but the validation shape is identical. This is argument validation, not a search failure.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/daytona_sandbox_tool/daytona_file_tool.py:301
if path is None:
raise ValueError("action='info' requires 'path'")
return self._info(sandbox, path)
if action == "exists":
if path is None:
raise ValueError("action='exists' requires 'path'")
return self._exists(sandbox, path)
if action == "move":
if path is None or destination is None:
raise ValueError("action='move' requires 'path' and 'destination'")
sandbox.fs.move_files(path, destination)
return {"status": "moved", "from": path, "to": destination}
if action == "find":
if path is None or pattern is None:
raise ValueError("action='find' requires 'path' and 'pattern'")
return self._find(sandbox, path, pattern)
if action == "search":
if path is None or pattern is None:
raise ValueError("action='search' requires 'path' and 'pattern'")
return self._search(sandbox, path, pattern)
if action == "chmod":
if path is None:
raise ValueError("action='chmod' requires 'path'")
return self._chmod(sandbox, path, mode=mode, owner=owner, group=group)
if action == "replace":
if paths is None or pattern is None or replacement is None:
raise ValueError(
"action='replace' requires 'paths', 'pattern', and "
"'replacement'"
)
return self._replace(sandbox, paths, pattern, replacement)
raise ValueError(f"Unknown action: {action}")
finally:
self._release_sandbox(sandbox, should_delete)
def _read(self, sandbox: Any, path: str, *, binary: bool) -> dict[str, Any]:
data: bytes = sandbox.fs.download_file(path)View on GitHub (pinned to 754d7323be)
Solutions
- Pass both arguments: _run(action='search', path='/src/app', pattern='API_KEY').
- Validate that action='search' calls include path and pattern before invoking the tool.
- Clarify in the tool description that pattern here is content text/regex, not a filename glob.
Example fix
# before file_tool._run(action='search', query='API_KEY') # after file_tool._run(action='search', path='/src/app', pattern='API_KEY')
Defensive patterns
Strategy: validation
Validate before calling
def search_contents(file_tool, path: str | None, pattern: str | None):
if not path or not pattern:
raise ValueError("action='search' requires 'path' and 'pattern'")
return file_tool._run(action='search', path=path, pattern=pattern) Try / catch
try:
res = file_tool._run(action='search', path=path, pattern=pattern)
except ValueError as e:
if "action='search'" in str(e):
return {'error': 'missing path or pattern', 'retry_with': {'path': path, 'pattern': pattern}}
raise Prevention
- Map 'query'-style agent fields to 'pattern' explicitly before dispatch.
- Prefer explicit wrappers per action over raw _run calls.
- Smoke-test search with a known file and literal pattern.
When it happens
Trigger: Calling _run(action='search', path='/src') with no pattern; _run(action='search', pattern='TODO') with no path; agents swapping in 'query' or 'regex' as the kwarg name.
Common situations: Agents emitting a generic 'query' field instead of 'pattern'; users assuming search defaults to the whole sandbox; mixing up find and search argument expectations.
Related errors
- action='delete' requires 'path'
- action='mkdir' requires 'path'
- action='info' requires 'path'
- action='exists' requires 'path'
- action='move' requires 'path' and 'destination'
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/afcd2b8348a588e3.
Report an issue: GitHub.