{"record":{"id":"eb09c01026ffb0e2","repo":"crewAIInc/crewAI","slug":"action-find-requires-pattern-text-to-search-f","errorCode":null,"errorMessage":"action='find' requires 'pattern' (text to search for inside files).","messagePattern":"action='find' requires 'pattern' \\(text to search for inside files\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/daytona_sandbox_tool/daytona_file_tool.py","lineNumber":197,"sourceCode":"    )\n    group: str | None = Field(\n        default=None,\n        description=\"For action='chmod': new file group.\",\n    )\n\n    @model_validator(mode=\"after\")\n    def _validate_action_args(self) -> DaytonaFileToolSchema:\n        if self.action != \"replace\" and not self.path:\n            raise ValueError(f\"action={self.action!r} requires 'path'.\")\n        if self.action == \"append\" and self.content is None:\n            raise ValueError(\n                \"action='append' requires 'content'. Pass the chunk to append \"\n                \"in the 'content' field.\"\n            )\n        if self.action == \"move\" and not self.destination:\n            raise ValueError(\"action='move' requires 'destination'.\")\n        if self.action == \"find\" and not self.pattern:\n            raise ValueError(\n                \"action='find' requires 'pattern' (text to search for inside files).\"\n            )\n        if self.action == \"search\" and not self.pattern:\n            raise ValueError(\"action='search' requires 'pattern' (glob, e.g. '*.py').\")\n        if self.action == \"chmod\" and not (self.mode or self.owner or self.group):\n            raise ValueError(\n                \"action='chmod' requires at least one of 'mode', 'owner', or 'group'.\"\n            )\n        if self.action == \"replace\":\n            if not self.paths:\n                raise ValueError(\n                    \"action='replace' requires 'paths' (list of file paths).\"\n                )\n            if not self.pattern:\n                raise ValueError(\"action='replace' requires 'pattern'.\")\n            if self.replacement is None:\n                raise ValueError(\"action='replace' requires 'replacement'.\")\n        return self","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/daytona_sandbox_tool/daytona_file_tool.py#L179-L215","documentation":"DaytonaFileToolSchema._validate_action_args requires action='find' to carry a pattern, because 'find' means full-text search inside files and needs the text to look for. A missing/empty pattern fails validation with this ValueError.","triggerScenarios":"Calling DaytonaFileTool with action='find' and a path/directory but no pattern; confusing 'find' (grep-like content search) with 'search' (glob filename search) and passing the wrong kind of argument or none.","commonSituations":"Agent mixes up find (text inside files) and search (glob like '*.py'); caller assumes find lists files without criteria; pattern variable empty due to upstream escaping/quoting bug.","solutions":["Pass the text to locate: tool.run(action='find', path='/workspace', pattern='TODO').","If you want filename matching instead, use action='search' with a glob pattern such as '*.py'.","Validate that the pattern string is non-empty before invoking the tool."],"exampleFix":"# before\ntool.run(action=\"find\", path=\"/workspace\")  # ValueError\n\n# after\ntool.run(action=\"find\", path=\"/workspace\", pattern=\"def main\")","handlingStrategy":"validation","validationCode":"def validate_find(path: str | None, pattern: str | None) -> None:\n    if not path:\n        raise ValueError(\"find requires path (directory)\")\n    if not pattern:\n        raise ValueError(\"find requires pattern = text to search inside files\")\n\nvalidate_find(path, pattern)","typeGuard":null,"tryCatchPattern":"try:\n    tool.run(action=\"find\", path=p, pattern=pat)\nexcept ValidationError as e:\n    if \"requires 'pattern'\" in str(e) and \"text to search\" in str(e):\n        pat = default_search_text\n        tool.run(action=\"find\", path=p, pattern=pat)\n    else:\n        raise","preventionTips":["Remember find = grep (contents), search = glob (filenames).","Always pair a directory path with the search text.","Document the two search modes in agent tool descriptions to prevent LLM mix-ups."],"tags":["daytona","pydantic","validation","input-validation","search"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}