langflow-ai/langflow · error · HTTPException

Knowledge base '{kb_name}' already exists

Error message

Knowledge base '{kb_name}' already exists

What it means

Error "Knowledge base '{kb_name}' already exists" thrown in langflow-ai/langflow.

Source

Thrown at src/backend/base/langflow/api/v1/knowledge_bases.py:739

        if not kb_name or len(kb_name) < MIN_KB_NAME_LENGTH:
            raise HTTPException(status_code=400, detail="Knowledge base name must be at least 3 characters")

        # Security: resolve paths and validate containment to prevent path traversal attacks.
        # A crafted kb_name like "../victim/evil" or an absolute path like "/tmp/evil" must be
        # rejected before any directory is created.
        kb_user_path = (kb_root_path / kb_user).resolve()
        kb_path = (kb_user_path / kb_name).resolve()
        # The username also roots the path, so it must be contained within the KB root
        # too (a username with ".." would otherwise escape it before mkdir).
        _validate_kb_path_containment(kb_root_path.resolve(), kb_user_path, kb_name, kb_user)
        _validate_kb_path_containment(kb_user_path, kb_path, kb_name, kb_user)

        # Check both durable DB state and legacy disk state. During
        # expand/contract rollout a KB row can exist even if its local
        # sidecar directory was cleaned up out of band.
        existing_record = await knowledge_base_service.get_by_user_and_name(current_user.id, kb_name)
        if existing_record is not None:
            raise HTTPException(status_code=409, detail=f"Knowledge base '{kb_name}' already exists")
        if kb_path.exists():
            # No DB row but a directory survives.  Two paths fork here:
            # the dir is a leftover from a previous failed delete (carries
            # the .kb_deleted sentinel) -- in which case the user clearly
            # wants to reuse the name -- vs. a legitimate orphan from a
            # legacy export.  Only the sentinel case is safe to repurpose.
            if KBStorageHelper.is_kb_dir_deleted(kb_path):
                raise HTTPException(
                    status_code=409,
                    detail=(
                        f"Knowledge base '{kb_name}' was recently deleted but its on-disk files "
                        "are still being released by another process. Restart the server (or wait "
                        "for the lock to clear) before recreating it with the same name."
                    ),
                )
            raise HTTPException(status_code=409, detail=f"Knowledge base '{kb_name}' already exists")

        # Create KB directory.  Clear any leftover sentinel just in case

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Choose a different name, or delete the existing knowledge base first.

When it happens

Trigger: Occurs when creating a knowledge base with a name that already exists for the current user.

Common situations: See trigger scenarios.


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/9f8812c056ecb13c. Report an issue: GitHub.