fix: reject empty table name in register-table endpoint
Fixes #8 — empty name created orphaned record that couldn't be deleted.
This commit is contained in:
parent
bd0b6d19c6
commit
78f003f5b5
1 changed files with 3 additions and 1 deletions
|
|
@ -84,8 +84,10 @@ async def register_table(
|
||||||
conn: duckdb.DuckDBPyConnection = Depends(_get_db),
|
conn: duckdb.DuckDBPyConnection = Depends(_get_db),
|
||||||
):
|
):
|
||||||
"""Register a new table in the system."""
|
"""Register a new table in the system."""
|
||||||
|
if not request.name or not request.name.strip():
|
||||||
|
raise HTTPException(status_code=422, detail="Table name cannot be empty")
|
||||||
repo = TableRegistryRepository(conn)
|
repo = TableRegistryRepository(conn)
|
||||||
table_id = request.name.lower().replace(" ", "_")
|
table_id = request.name.strip().lower().replace(" ", "_")
|
||||||
|
|
||||||
if repo.get(table_id):
|
if repo.get(table_id):
|
||||||
raise HTTPException(status_code=409, detail=f"Table '{table_id}' already registered")
|
raise HTTPException(status_code=409, detail=f"Table '{table_id}' already registered")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue