Skip to content

Python: Omit null fields from Redis context writes - #9069

Open
LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/redis-optional-record-fields
Open

LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/redis-optional-record-fields

Conversation

@ktz03

Copy link
Copy Markdown
Contributor

Motivation & Context

An injected Redis context index uses RedisVL's default non-validating load path. Ordinary messages and unset scope fields can contain None, which Redis HASH encoding rejects. Provider-created indexes already omit these null values through RedisVL validation; writes through supplied indexes should have the same behavior.

Description & Review Guide

  • What are the major changes? Omit only None values from the prepared document copies immediately before loading, after embedding generation. Add seven SDK-chain regressions for public message writes, optional scopes and session fields, supplied IDs, null placeholders, and binary/generated vectors.
  • What is the impact of these changes? Both supplied and provider-created indexes can encode messages with absent optional fields. Scope filters, valid supplied IDs, zero values, empty strings, vector bytes, and caller inputs remain intact. The Redis unit suite passes 325 tests with 93.35% coverage; 48 integration tests were deselected. Ruff, source Pyright, all five test type checkers, pre-commit checks, and the package build pass. The SDK-chain tests replace network transport; no live Redis server, authentication, or model service was tested.
  • What do you want reviewers to focus on? Null omission after vectors are populated, preservation of non-null values and caller input, and parity with RedisVL's existing validated load path. Generic RedisCollection HASH null validation is unchanged.

Related Issue

Fixes #9067

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 17:01
@ktz03
LI (ktz03) deployed to github-app-auth October 5, 2026 17:01 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 5, 2026
@ktz03
LI (ktz03) deployed to github-app-auth October 5, 2026 17:14 — with GitHub Actions Active

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.

Copilot review overview

🟢 Approval recommended

The focused fix preserves non-null data and vectors while comprehensively covering the reported failure.

Review effort: Balanced
Findings: None

What changed in this PR

Aligns injected Redis context indexes with provider-created indexes by omitting null fields before HASH writes.

Changes:

  • Removes None values after vector generation without mutating caller inputs.
  • Adds regression coverage for scopes, IDs, placeholders, and vectors.
File Description
python/​packages/​redis/​agent_framework_redis/​_context_provider.py Filters null fields before RedisVL loading.
python/​packages/​redis/​tests/​test_context_provider_sdk.py Tests owned and borrowed index write behavior.

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

This branch was successfully deployed

1 active deployment
github-app-auth — c21abd92 Deployed Oct 9, 2026 by ktz03 via team_check #6415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Injected Redis context indexes cannot encode optional null message fields

2 participants