{"record":{"id":"eb4ab1097bf75b38","repo":"zylon-ai/private-gpt","slug":"unable-to-create-file","errorCode":null,"errorMessage":"Unable to create file","messagePattern":"Unable to create file","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tools/builders/text_editor_tool_builder.py","lineNumber":181,"sourceCode":"                },\n            ),\n        )\n\n    async def build_create_tool(\n        self,\n        config: CodeExecutionSessionConfig,\n        name: str = TEXT_EDITOR_CREATE_TOOL_NAME,\n        type: str = TEXT_EDITOR_CREATE_TOOL_NAME + \"_v1\",\n        description: str = TEXT_EDITOR_CREATE_TOOL_FN.metadata.description,\n    ) -> ToolSpec:\n        async def create(\n            path: str,\n            file_text: str,\n        ) -> list[ResultContentBlockType]:\n            session = await self._session(config)\n            result = await session.create(path, file_text)\n            if not result.success:\n                raise RuntimeError(result.error or \"Unable to create file\")\n            return [TextEditorCodeExecutionCreateResultBlock(is_file_update=False)]\n\n        return ToolSpec.from_defaults(\n            name=name,\n            type=type,\n            runtime=\"server\",\n            event_adapter=TextEditorCodeExecutionEventAdapter,\n            description=description,\n            async_fn=create,\n            requirements=[ToolRequirements.SANDBOX],\n            execution_metadata=build_rebuild_metadata(\n                rebuild_text_editor_create_tool,\n                {\n                    \"config\": config,\n                    \"name\": name,\n                    \"type\": type,\n                    \"description\": description,\n                },","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tools/builders/text_editor_tool_builder.py#L163-L199","documentation":"RuntimeError from the create tool: session.create(path, file_text) returned success=False. Message is result.error when available, otherwise 'Unable to create file'. The session-side create fails on unwritable/invalid paths, existing files (providers commonly refuse to overwrite), or sandbox permission limits.","triggerScenarios":"Calling create for a path whose parent directory does not exist, a path that already exists (tool semantics are create-new, note is_file_update=False in the success block), or a location outside the sandbox's writable area.","commonSituations":"Agent calls create for a file that already exists instead of using an edit command; missing parent directories in deep paths; read-only mount in the sandbox container; expired session.","solutions":["Check result.error in the exception message for the session's specific reason; if generic, wrap and log it.","Ensure the parent directory exists (create it via bash tool or use an existing directory) and the path is within the sandbox workspace.","If the file already exists, use the appropriate edit/replace command rather than create.","Recreate the session if the TTL expired and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# before create: ensure it is a new file inside an existing directory\nimport posixpath\nassert not path_exists_in_sandbox(path), f\"{path} already exists; use an edit command\"\nassert posixpath.dirname(path), \"create files inside an existing directory\"","typeGuard":null,"tryCatchPattern":"try:\n    blocks = await create(path=path, file_text=text)\nexcept RuntimeError as e:\n    detail = str(e) if str(e) != \"Unable to create file\" else \"create failed without detail\"\n    if \"exists\" in detail:\n        # switch to str_replace/edit flow instead of create\n        pass\n    raise","preventionTips":["Treat create as new-file-only; route edits through the replace/view commands.","Create parent directories first (bash tool) for nested paths.","Stay inside the sandbox's writable workspace directory."],"tags":["text-editor","code-execution","file-create","sandbox"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}