Skip to content

Python: Preserve configured search filters for invalid overrides - #14645

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
mainfrom
sk-search-filter-isolation
Oct 23, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
mainfrom
sk-search-filter-isolation

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation and Context

Search functions retain caller-configured options, including filters, while accepting invocation-time overrides. When an invocation override failed validation, the fallback replaced all configured options with blank defaults. This change preserves the configured baseline while continuing to ignore invalid overrides.

Description

  • Rebuild text and vector search fallback options from their configured baseline rather than empty defaults.
  • Add regression coverage using an invalid top=0 override and verify that the configured filter still reaches the search call.
  • Keep the public API and tolerant invalid-override behavior unchanged.

Validation:

  • uv run --python 3.12 --frozen --extra pandas pytest tests\unit\data\test_text_search.py tests\unit\data\test_vector_search_base.py --quiet — passed, 20 tests; one existing event-loop deprecation warning.
  • uv run --python 3.12 --frozen ruff check semantic_kernel\data\text_search.py semantic_kernel\data\vector.py tests\unit\data\test_text_search.py tests\unit\data\test_vector_search_base.py — passed.
  • git diff --check — passed.

Full Python unit tests and uv run pre-commit run -a were not run.

Contribution Checklist

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fallback changes preserve configured options, and regression tests cover filter retention in both affected search wrappers.

No open issues 🎉

What changed in this PR

This PR fixes search-option fallback behavior so invalid invocation-time overrides preserve configured options, including filters, rather than replacing them with empty defaults.

Changes:

  • Rebuild fallback options from the configured baseline in text and vector search wrappers.
  • Add regression tests verifying that configured filters reach both search calls when an invalid top=0 override is supplied.
  • Preserve the public API and tolerant handling of invalid overrides.
File Description
python/​tests/​unit/​data/​test_vector_search_base.py Tests vector-search filter retention after an invalid override.
python/​tests/​unit/​data/​test_text_search.py Tests text-search filter retention after an invalid override.
python/​semantic_kernel/​data/​vector.py Restores configured vector-search options on validation failure.
python/​semantic_kernel/​data/​text_search.py Restores configured text-search options on validation failure.

Review effort: Balanced

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
data
   text_search.py69297%229, 240
   vector.py6568986%83, 413, 579, 698, 896–899, 905, 907–908, 1026, 1064–1065, 1068, 1075, 1095–1102, 1104, 1106–1107, 1109, 1111, 1114–1119, 1121–1126, 1148, 1171, 1308, 1461, 1476, 1482–1483, 1485, 1512, 1586–1587, 1599–1600, 1714, 1719–1722, 1836, 1903, 1923, 1931–1932, 1944, 1951, 2055, 2108–2114, 2118–2123, 2127, 2158, 2172, 2180, 2219, 2243, 2257, 2303, 2343
TOTAL29159544081% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4520 22 💤 0 ❌ 0 🔥 2m 25s ⏱️

@jpalvarezl Jose Alvarez (jpalvarezl) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback now rebuilds from the configured baseline after an invalid invocation override, preserving filters and other configured options. The custom filter updater still runs afterward, so intentional clearing remains available without changing validation behavior.

This branch was successfully deployed

1 active and 1 inactive deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants