llamaIndex - ✅(Solved) Fix [Bug]: falsy metadata values stored as None in Azure AI Search index [3 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#21385Fetched 2026-04-16 06:35:52
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3labeled ×2referenced ×1

Fix Action

Fixed

PR fix notes

PR #21386: fix(azureaisearch): preserve falsy metadata values in index mapping

Description (problem / solution / changelog)

PR Title

fix(azureaisearch): preserve falsy metadata values in index mapping

PR Body

Description

Preserves falsy metadata values when mapping metadata fields into Azure AI Search index documents.

Previously, _default_index_mapping() only wrote metadata fields when the value was truthy, which caused valid values like 0, "", and [] to be dropped before indexing. This change updates the check to preserve all values except None and adds a regression test covering those falsy cases.

Fixes #21385

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Targeted test run:

uv run --directory llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch pytest tests/test_azureaisearch.py -k preserves_falsy_metadata_values

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

Changed files

  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py (modified, +1/-1)
  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/tests/test_azureaisearch.py (modified, +42/-0)

PR #21387: fix(azureaisearch): falsy metadata stored as None in Azure AI Search

Description (problem / solution / changelog)

Description

Fixed falsy metadata stored as None in Azure AI Search.

Fixes #21385

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

Changed files

  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py (modified, +1/-1)
  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/pyproject.toml (modified, +1/-1)
  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/tests/test_azureaisearch.py (modified, +41/-0)
  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/uv.lock (modified, +3063/-3063)

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

Description (problem / solution / changelog)

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

Changed files

  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py (modified, +1/-1)
RAW_BUFFERClick to expand / collapse

Bug Description

Falsy metadata values (0, "", []) are stored as None in Azure AI Search index.

Version

0.4.0

Steps to Reproduce

Create an Azure AI Search index with a metadata value that is an integer. Add a node with metadata value = 0. Retrieve the node from the index and the value is None instead of 0.

https://github.com/run-llama/llama_index/blob/91fe33e75ce31d3ca447c017a5ea153ed8b38700/llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py#L899

Change above line to:

if metadata_value is not None:

Relevant Logs/Tracebacks

extent analysis

TL;DR

The issue can likely be fixed by modifying the condition to handle falsy metadata values correctly.

Guidance

  • The current implementation sets metadata values to None when they are falsy (e.g., 0, "", []), which is incorrect.
  • To fix this, the condition if metadata_value is not None: should be modified to also handle falsy values, for example, by checking for empty strings, zero, or empty lists explicitly.
  • The provided code change suggests a potential fix, but its correctness depends on the specific requirements of the Azure AI Search index and how it handles metadata values.
  • Verify the fix by creating a test case with a metadata value of 0 and checking if it is correctly stored and retrieved from the index.

Example

if metadata_value is not None and metadata_value not in [0, "", [], {}]:
    # store metadata value

Note: This example is a simple illustration and might need adjustments based on the actual requirements and implementation.

Notes

The provided fix assumes that falsy values should be stored as is. However, the correct handling of these values depends on the specific use case and requirements of the application.

Recommendation

Apply workaround: Modify the condition to correctly handle falsy metadata values, as the provided change suggests, and test it thoroughly to ensure it meets the application's requirements.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING