Skip to content

Fix VADD updates with empty attributes - #4430

Merged
petyaslavova merged 4 commits into
redis:masterfrom
Ganesh1729-ui:fix/vadd-empty-attributes
Oct 15, 2026
Merged

petyaslavova merged 4 commits into
redis:masterfrom
Ganesh1729-ui:fix/vadd-empty-attributes

Conversation

@Ganesh1729-ui

@Ganesh1729-ui Ganesh1729-ui commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

VADD currently drops an explicit empty dictionary or empty string from attributes. When updating an existing vector, its previous metadata survives. The equivalent JSON string "{}" already sends SETATTR.

For example, against a local Redis server supporting vector sets:

import redis

vset = redis.Redis(decode_responses=True).vset()
vset.vadd("vadd-attributes-repro", [1, 0], "doc", attributes={"source": "old"})
vset.vadd("vadd-attributes-repro", [0, 1], "doc", attributes={})
print(vset.vgetattr("vadd-attributes-repro", "doc"))
# Before: {'source': 'old'}; after: None (the existing empty-object callback result).

This affects re-indexing when replacement metadata becomes empty. Discovered through code analysis, then reproduced with command probes and a real Redis 8.10.2 server; no production incident is claimed.

Check attributes is not None in the shared sync/async command builder. This forwards {} as SETATTR '{}' and "" as attribute removal, while None still leaves existing attributes unchanged. This follows Redis's VADD contract and its existing server update behavior. Signatures and response callbacks are unchanged.

Add sync/async regressions for updates with {}, "{}", "", None and a nonempty replacement. The prior empty-dict test adds a new vector, where omission cannot expose stale attributes.

Validation:

  • New real-server tests on unchanged source: 6 failed / 9 controls passed; patched: all pass.
  • Full vector modules, pytest tests/test_vsets.py tests/test_asyncio/test_vsets.py -q, with Redis 8.10.2 and Python 3.13.16: 147 passed in each RESP2/RESP3 Γ— legacy/unified configuration. One unchanged capture configuration warning per run. Fork validation.
  • Full configured default lane using the project's test action, Redis 8.10.2 / Python 3.13 / plain parser / asyncio / legacy responses: 2,856 fixed-client passes, 3,674 standalone passes, 1,913 cluster passes, with 954 existing skips and eight existing expected-failure cases passing. Completed fork run. External scenario and multidatabase integration suites are outside this lane.
  • Windows Python 3.13.7 sync/async command probes: 4 failures before / 10 passes after; fresh installed-wheel probes: 10 passes.
  • invoke linters (Ruff and Vulture), sdistβ†’wheel builds on Windows/Linux, and diff checks pass.

The separate fork validation workflow is absent from this three-file contribution. The remaining Redis/Python/parser/event-loop version matrix was not run locally. AI assistance was used for source investigation, implementation, validation and this description.


Note

Low Risk
Small, targeted change to VADD argument encoding with added tests; behavior change only affects callers that pass empty dict/string to clear or reset attributes on update.

Overview
Fixes vadd so explicit empty or clearing attribute values are sent on updates to an existing element, instead of being dropped and leaving stale metadata.

The command builder now uses attributes is not None (replacing a truthiness check), so {} and "{}" emit SETATTR with an empty object and "" clears attributes, while None still omits SETATTR and preserves existing attributes. Docstrings describe this behavior.

Sync and async regression tests cover re-adding the same element with {}, "{}", "", None, and a nonempty replacement.

Reviewed by Cursor Bugbot for commit c1b796e. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-15T10:19:18.086610Z c1b796e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @Ganesh1729-ui, thank you for your contribution! LGTM.

Copy link
Copy Markdown

Thanks for reviewing and approving this PR. I appreciate your feedback.

@petyaslavova
petyaslavova merged commit 8a81373 into redis:master Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants