fix: add safety check for empty model_suffix in PostgreSQL vector storage
Why this change is needed: Prevent potential errors when embedding_func does not have model_name set, which could cause table naming issues in PostgreSQL. How it solves it: - Check if model_suffix is not empty before appending to table name - Fall back to base table name with a warning if model_suffix is unavailable - Log clear warning message to alert users about missing model isolation Impact: - Prevents crashes when model_name is not configured - Provides clear feedback to users about configuration issues - Maintains backward compatibility with configs that don't set model_name Testing: Existing PostgreSQL tests validate the happy path. This adds defensive handling for edge cases.
This commit is contained in:
parent
19caf9f27c
commit
84ff11f1d9
1 changed files with 10 additions and 1 deletions
|
|
@ -2231,7 +2231,16 @@ class PGVectorStorage(BaseVectorStorage):
|
|||
raise ValueError(f"Unknown namespace: {self.namespace}")
|
||||
|
||||
# New table name (with suffix)
|
||||
self.table_name = f"{base_table}_{self.model_suffix}"
|
||||
# Ensure model_suffix is not empty before appending
|
||||
if self.model_suffix:
|
||||
self.table_name = f"{base_table}_{self.model_suffix}"
|
||||
else:
|
||||
# Fallback: use base table name if model_suffix is unavailable
|
||||
self.table_name = base_table
|
||||
logger.warning(
|
||||
f"Model suffix unavailable, using base table name '{base_table}'. "
|
||||
f"Ensure embedding_func has model_name for proper model isolation."
|
||||
)
|
||||
|
||||
# Legacy table name (without suffix, for migration)
|
||||
self.legacy_table_name = base_table
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue