From c34a2a8ee84d8cf0eeda5afa41418f7b63b4c3d5 Mon Sep 17 00:00:00 2001 From: reluctantfuturist Date: Mon, 3 Mar 2025 23:27:45 -0800 Subject: [PATCH] fix(pgvector): replace hyphens with underscores in table names --- llama_stack/providers/remote/vector_io/pgvector/pgvector.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llama_stack/providers/remote/vector_io/pgvector/pgvector.py b/llama_stack/providers/remote/vector_io/pgvector/pgvector.py index 269cf554b..7c683e126 100644 --- a/llama_stack/providers/remote/vector_io/pgvector/pgvector.py +++ b/llama_stack/providers/remote/vector_io/pgvector/pgvector.py @@ -58,7 +58,11 @@ class PGVectorIndex(EmbeddingIndex): def __init__(self, vector_db: VectorDB, dimension: int, conn): self.conn = conn with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur: - self.table_name = f"vector_store_{vector_db.identifier}" + # Sanitize the table name by replacing hyphens with underscores + # SQL doesn't allow hyphens in table names, and vector_db.identifier may contain hyphens + # when created with patterns like "test-vector-db-{uuid4()}" + sanitized_identifier = vector_db.identifier.replace("-", "_") + self.table_name = f"vector_store_{sanitized_identifier}" cur.execute( f"""