Skip to content

Python: Preserve falsy dynamic search filter defaults - #14303

Open
Tyyyy (uczltw6) wants to merge 1 commit into
microsoft:mainfrom
uczltw6:codex/preserve-falsy-filter-defaults
Open

Python: Preserve falsy dynamic search filter defaults#14303
Tyyyy (uczltw6) wants to merge 1 commit into
microsoft:mainfrom
uczltw6:codex/preserve-falsy-filter-defaults

Conversation

@uczltw6

Copy link
Copy Markdown

Motivation and Context

Dynamic search parameters with a default value are documented as adding equality filters. The current truthiness check drops valid falsy defaults such as 0, False, and an empty string, so invoking the generated search function without an override silently broadens the search.

Description

Treat every non-None parameter default as an explicit filter value. The regression test exercises the public create_search_function path and verifies that all three falsy defaults reach the underlying search as filters.

OpenAI Codex assisted with identifying the edge case and preparing the focused change. The behavior, diff, and test results were verified locally.

Validation

  • uv run pytest tests/unit/connectors/memory/test_in_memory.py tests/unit/data -ra — 122 passed
  • uv run pre-commit run --files semantic_kernel/data/_shared.py tests/unit/data/test_text_search.py — all hooks passed
  • uv run mypy -p semantic_kernel --config-file mypy.ini — no issues in 555 source files

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines and the pre-submission formatting checks raise no violations
  • All relevant unit tests pass, and I added regression coverage
  • I didn't break anyone 😄

Copilot AI lite review requested due to automatic review settings August 19, 2026 05:15
@uczltw6
Tyyyy (uczltw6) requested a review from a team as a code owner August 19, 2026 05:15

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates dynamic filter generation to apply parameter default values even when they’re falsy (e.g., 0, False, "") and adds unit tests to validate the behavior.

Changes:

  • Fix default-value handling in dynamic filter construction by checking is not None instead of truthiness.
  • Add a parametrized unit test ensuring falsy defaults are translated into filter expressions correctly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/semantic_kernel/data/_shared.py Adjusts default filter generation to include falsy (but non-None) defaults.
python/tests/unit/data/test_text_search.py Adds parametrized coverage for falsy default values in filter generation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

assert results.value == ["test"]


@pytest.mark.parametrize(("default_value", "expected_literal"), [(0, "0"), (False, "False"), ("", "''")])
assert results.value == ["test"]


@pytest.mark.parametrize(("default_value", "expected_literal"), [(0, "0"), (False, "False"), ("", "''")])
@uczltw6

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@uczltw6
Tyyyy (uczltw6) force-pushed the codex/preserve-falsy-filter-defaults branch from 9ebb17f to 5e947bf Compare August 19, 2026 06:57
@github-actions

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
data
   _shared.py64789%136, 142, 168, 175, 178–179, 181
TOTAL29020561780% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4094 23 💤 0 ❌ 0 🔥 2m 10s ⏱️

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.

2 participants