{"record":{"id":"918b1fd24217d114","repo":"infiniflow/ragflow","slug":"ragflow-target-folder-does-not-exist-or-is-not-a-f","errorCode":null,"errorMessage":"RAGFlow target folder does not exist or is not a folder: {parent_id}","messagePattern":"RAGFlow target folder does not exist or is not a folder: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/browser.py","lineNumber":583,"sourceCode":"                continue\n            except Exception as e:\n                logging.warning(\"Browser failed to fetch upload blob. file_id=%s, error=%s\", file_id, e)\n                continue\n            prepared.append(\n                {\n                    \"file_id\": file.id,\n                    \"name\": file.name,\n                    \"size\": file.size,\n                    \"local_path\": local_path,\n                }\n            )\n        return prepared\n\n    def _save_downloads(self, download_dir: str, parent_id: str) -> list[dict[str, Any]]:\n        downloaded_files: list[dict[str, Any]] = []\n        exists, folder = FileService.get_by_id(parent_id)\n        if not exists or folder.type != FileType.FOLDER.value:\n            raise ValueError(f\"RAGFlow target folder does not exist or is not a folder: {parent_id}\")\n        tenant_id = self._canvas.get_tenant_id()\n        storage_put = settings.STORAGE_IMPL.put\n        storage_rm = getattr(settings.STORAGE_IMPL, \"rm\", None)\n        insert_file = FileService.insert\n\n        for path in Path(download_dir).rglob(\"*\"):\n            if not path.is_file():\n                continue\n            try:\n                if path.stat().st_size <= 0:\n                    continue\n                blob = path.read_bytes()\n            except OSError as e:\n                logging.warning(\"Browser failed to read downloaded file. path=%s, error=%s\", path, e)\n                continue\n            if not blob:\n                continue\n            display_name = \"\"","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/browser.py#L565-L601","documentation":"Raised in the Browser component's _save_downloads (agent/component/browser.py) when saving downloaded browser files into RAGFlow storage: FileService.get_by_id(parent_id) either found no file record, or the record's type is not FOLDER. The component requires a real RAGFlow knowledge-base folder as the destination for browser downloads.","triggerScenarios":"Configuring the Browser component's save-to folder with a parent_id that is a document id, a dataset/kb root that is not typed as FOLDER, an id from another tenant, or a deleted folder. Fires at run time after the browser session downloads files and the component tries to persist them.","commonSituations":"Hand-copying a file id instead of a folder id into the canvas config; deleting the target folder in the UI after the canvas was saved; using a folder id from a different environment/tenant on import; frontends defaulting parent_id to an empty string or a dataset id.","solutions":["In the Browser component settings, re-pick the destination folder from the valid RAGFlow folder tree","Verify the id: query FileService/the files table and confirm the record exists and type == 'folder' for the canvas tenant","If the folder was deleted, recreate it and update the component configuration","Ensure the tenant that owns the canvas is the tenant that owns the folder"],"exampleFix":"# before\n\"save_to\": \"<document-file-id>\"\n\n# after\n\"save_to\": \"<folder-id>\"  # FileService.get_by_id(...)[1].type == FileType.FOLDER.value","handlingStrategy":"validation","validationCode":"from api.db.services.file_service import FileService\nfrom api.db import FileType\n\ndef validate_target_folder(tenant_id, parent_id):\n    exists, folder = FileService.get_by_id(parent_id)\n    if not exists or folder.type != FileType.FOLDER.value:\n        raise ValueError(f'parent_id {parent_id} is not a valid RAGFlow folder for this tenant')\n    return parent_id","typeGuard":"def is_ragflow_folder(parent_id) -> bool:\n    exists, folder = FileService.get_by_id(parent_id)\n    return bool(exists) and folder.type == FileType.FOLDER.value","tryCatchPattern":"try:\n    component.run(...)\nexcept ValueError as e:\n    if 'target folder does not exist' in str(e):\n        reconfigure_component(component, pick_folder_again=True)\n    else:\n        raise","preventionTips":["Choose the download destination via the folder picker, never by pasting raw ids","Re-validate folder references after deleting/moving folders in the KB UI","Keep canvases and their target folders in the same tenant"],"tags":["agent-component","browser-use","file-storage","configuration"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}