Skip to content

fix: preserve falsy metadata values in Azure AI Search vector store#21388

Open
voidborne-d wants to merge 1 commit intorun-llama:mainfrom
voidborne-d:fix/azureaisearch-falsy-metadata-values
Open

fix: preserve falsy metadata values in Azure AI Search vector store#21388
voidborne-d wants to merge 1 commit intorun-llama:mainfrom
voidborne-d:fix/azureaisearch-falsy-metadata-values

Conversation

@voidborne-d
Copy link
Copy Markdown

Problem

Falsy metadata values (0, "", [], False) are silently dropped when building the Azure AI Search index document.

The current truthiness check on line 899:

if metadata_value:

skips any value that evaluates to False in a boolean context, which includes valid values like integer 0, empty strings, and empty lists.

Fix

Replace the truthiness check with an explicit None check:

if metadata_value is not None:

This ensures only truly absent metadata keys are skipped, while all valid falsy values are preserved in the index.

Reproducing

  1. Create an Azure AI Search index with an integer metadata field
  2. Add a node with that metadata field set to 0
  3. Retrieve the node — the value comes back as None instead of 0

Fixes #21385

The truthiness check `if metadata_value:` silently drops valid
falsy values like 0, "", [], and False when building the index
document.  Replace with an explicit `is not None` check so that
only truly absent keys are skipped.

Fixes run-llama#21385
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: falsy metadata values stored as None in Azure AI Search index

1 participant