infiniflow/ragflow · error · ValueError

RAGFlow target folder does not exist or is not a folder: {pa

Error message

RAGFlow target folder does not exist or is not a folder: {parent_id}

What it means

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.

Source

Thrown at agent/component/browser.py:583

                continue
            except Exception as e:
                logging.warning("Browser failed to fetch upload blob. file_id=%s, error=%s", file_id, e)
                continue
            prepared.append(
                {
                    "file_id": file.id,
                    "name": file.name,
                    "size": file.size,
                    "local_path": local_path,
                }
            )
        return prepared

    def _save_downloads(self, download_dir: str, parent_id: str) -> list[dict[str, Any]]:
        downloaded_files: list[dict[str, Any]] = []
        exists, folder = FileService.get_by_id(parent_id)
        if not exists or folder.type != FileType.FOLDER.value:
            raise ValueError(f"RAGFlow target folder does not exist or is not a folder: {parent_id}")
        tenant_id = self._canvas.get_tenant_id()
        storage_put = settings.STORAGE_IMPL.put
        storage_rm = getattr(settings.STORAGE_IMPL, "rm", None)
        insert_file = FileService.insert

        for path in Path(download_dir).rglob("*"):
            if not path.is_file():
                continue
            try:
                if path.stat().st_size <= 0:
                    continue
                blob = path.read_bytes()
            except OSError as e:
                logging.warning("Browser failed to read downloaded file. path=%s, error=%s", path, e)
                continue
            if not blob:
                continue
            display_name = ""

View on GitHub (pinned to 554fb1133a)

Solutions

  1. In the Browser component settings, re-pick the destination folder from the valid RAGFlow folder tree
  2. Verify the id: query FileService/the files table and confirm the record exists and type == 'folder' for the canvas tenant
  3. If the folder was deleted, recreate it and update the component configuration
  4. Ensure the tenant that owns the canvas is the tenant that owns the folder

Example fix

# before
"save_to": "<document-file-id>"

# after
"save_to": "<folder-id>"  # FileService.get_by_id(...)[1].type == FileType.FOLDER.value
Defensive patterns

Strategy: validation

Validate before calling

from api.db.services.file_service import FileService
from api.db import FileType

def validate_target_folder(tenant_id, parent_id):
    exists, folder = FileService.get_by_id(parent_id)
    if not exists or folder.type != FileType.FOLDER.value:
        raise ValueError(f'parent_id {parent_id} is not a valid RAGFlow folder for this tenant')
    return parent_id

Type guard

def is_ragflow_folder(parent_id) -> bool:
    exists, folder = FileService.get_by_id(parent_id)
    return bool(exists) and folder.type == FileType.FOLDER.value

Try / catch

try:
    component.run(...)
except ValueError as e:
    if 'target folder does not exist' in str(e):
        reconfigure_component(component, pick_folder_again=True)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/918b1fd24217d114. Report an issue: GitHub.