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:
ZdenekSrotyr 2026-03-31 12:18:58 +02:00
parent bd0b6d19c6
commit 78f003f5b5

View file

@ -84,8 +84,10 @@ async def register_table(
conn: duckdb.DuckDBPyConnection = Depends(_get_db),
):
"""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)
table_id = request.name.lower().replace(" ", "_")
table_id = request.name.strip().lower().replace(" ", "_")
if repo.get(table_id):
raise HTTPException(status_code=409, detail=f"Table '{table_id}' already registered")