Skip to content

fix(config): call .strip() correctly in vector store db_uri validation#2412

Open
himanshupandeytech-ai wants to merge 1 commit into
microsoft:mainfrom
himanshupandeytech-ai:fix/vector-store-db-uri-strip-check
Open

fix(config): call .strip() correctly in vector store db_uri validation#2412
himanshupandeytech-ai wants to merge 1 commit into
microsoft:mainfrom
himanshupandeytech-ai:fix/vector-store-db-uri-strip-check

Conversation

@himanshupandeytech-ai

Copy link
Copy Markdown

Summary

Fixes #2381
The condition in _validate_vector_store_db_uri() used store.db_uri.strip without parentheses.
A bound method reference is always truthy, so the comparison store.db_uri.strip == "" was always False.
A whitespace-only db_uri was never replaced with the default and was passed directly to Path.resolve().

Fix

# Before
if not store.db_uri or store.db_uri.strip == "":
# After
if not store.db_uri or store.db_uri.strip() == "":

Tests

Added tests/unit/config/test_vector_store_db_uri_validation.py covering:

  • empty string, whitespace-only, tab-only, newline-only, mixed whitespace (all fall back to default)
  • None / omitted db_uri (falls back to default)
  • valid relative path (resolved to absolute)
  • valid absolute path (preserved)

The condition in _validate_vector_store_db_uri() compared the bound method
reference store.db_uri.strip (without parentheses) to an empty string.
A method reference is always truthy, so the comparison was always False —
meaning a whitespace-only db_uri was never replaced with the default and
was forwarded unchanged to Path.resolve(), silently producing a wrong path.

Fix: add parentheses to call the method and get the stripped string.

Fixes microsoft#2381

Tests added:
- Parametrized regression tests for empty, whitespace-only, tab, newline,
  and mixed-whitespace URIs (all must fall back to the configured default).
- Tests for None / omitted db_uri (existing degenerate case).
- Tests for valid relative and absolute URIs (must resolve correctly).
@himanshupandeytech-ai

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: vector store db_uri whitespace check uses .strip without parentheses, always False

3 participants