langflow-ai/langflow · error · HTTPException

Knowledge base name must be at least 3 characters

Error message

Knowledge base name must be at least 3 characters

What it means

Error "Knowledge base name must be at least 3 characters" thrown in langflow-ai/langflow.

Source

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

@router.post("", status_code=HTTPStatus.CREATED)
@router.post("/", status_code=HTTPStatus.CREATED)
async def create_knowledge_base(
    request: CreateKnowledgeBaseRequest,
    current_user: CurrentActiveUser,
) -> KnowledgeBaseInfo:
    """Create a new knowledge base with embedding configuration."""
    try:
        kb_root_path = KBStorageHelper.get_root_path()
        kb_user = current_user.username
        kb_name = request.name.strip().replace(" ", "_")
        await _guard_kb_action(
            current_user=current_user,
            action=KnowledgeBaseAction.CREATE,
            kb_name=kb_name or None,
        )
        # Validate KB name
        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():

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Use a knowledge base name of at least 3 characters.

When it happens

Trigger: Occurs when creating a knowledge base with a name shorter than 3 characters.

Common situations: See trigger scenarios.


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