Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions backend/modules/vector_db/singlestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ def list_data_point_vectors(
try:
curr = conn.cursor()

# Remove all data point vectors with the same data_source_fqn
# Using parameterized query to prevent SQL injection
query = f"SELECT id, content, vector, metadata FROM {collection_name} WHERE JSON_EXTRACT_JSON(metadata, %s) LIKE %s LIMIT %s"
curr.execute(
f"SELECT * FROM {collection_name} WHERE JSON_EXTRACT_JSON(metadata, '{DATA_POINT_FQN_METADATA_KEY}') LIKE '%{data_source_fqn}%' LIMIT {MAX_SCROLL_LIMIT}"
query,
(DATA_POINT_FQN_METADATA_KEY, f"%{data_source_fqn}%", MAX_SCROLL_LIMIT),
)

for record in curr:
Expand Down Expand Up @@ -286,8 +288,15 @@ def delete_data_point_vectors(
vectors_to_be_deleted_count = len(data_point_vectors)
curr = conn.cursor()

# Using parameterized query for multiple IDs
placeholders = ", ".join(["%s"] * len(data_point_vectors))
query = f"DELETE FROM {collection_name} WHERE id in ({placeholders})"
curr.execute(
f"DELETE FROM {collection_name} WHERE id in ({', '.join(data_point_vector.data_point_vector_id for data_point_vector in data_point_vectors)})"
query,
tuple(
data_point_vector.data_point_vector_id
for data_point_vector in data_point_vectors
),
)
logger.debug(
f"[SingleStore] Deleted {vectors_to_be_deleted_count} data point vectors"
Expand Down
5 changes: 3 additions & 2 deletions backend/server/routers/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ async def add_data_source(data_source: CreateDataSource):
tfy_client = get_tfy_client()
# TODO: Currently, if a TFY data directory does not exist, an exception is thrown.
# We need to raise a 404 error instead of failing generically.
data_dir = tfy_client.get_data_directory_by_fqn(data_source.uri)
tfy_client.get_data_directory_by_fqn(data_source.uri)
except Exception as e:
logger.error(f"Failed to validate TrueFoundry DataSource URI: {e}")
return JSONResponse(
content={"error": f"Invalid DataSource URI: {e}"}, status_code=400
content={"error": "Invalid DataSource URI or failed to connect to provider"}, status_code=400
)
# Create the data source record
created_data_source = await metadata_store_client.acreate_data_source(
Expand Down