Skip to content

Commit

Permalink
fix(backend): data source name should not be blank
Browse files Browse the repository at this point in the history
  • Loading branch information
wd0517 committed Sep 26, 2024
1 parent ae9ccee commit f1ea345
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/app/api/admin_routes/data_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel
from pydantic import BaseModel, field_validator
from fastapi import APIRouter, Depends, HTTPException, status
from fastapi_pagination import Params, Page

Expand Down Expand Up @@ -27,6 +27,12 @@ class DataSourceCreate(BaseModel):
build_kg_index: bool = False
llm_id: int | None = None

@field_validator("name")
def name_must_not_be_blank(cls, v: str) -> str:
if not v.strip():
raise ValueError("Please provide a name for the data source")
return v


@router.post("/admin/datasources")
def create_datasource(
Expand Down

0 comments on commit f1ea345

Please sign in to comment.