Skip to content

VSETATTR: the attribute string is not validated, no error reply - #4129

Merged
dwdougherty merged 2 commits into
redis:mainfrom
Laurianti:fix-vsetattr-reply
Sep 28, 2026
Merged

dwdougherty merged 2 commits into
redis:mainfrom
Laurianti:fix-vsetattr-reply

Conversation

@Laurianti

@Laurianti Laurianti commented Sep 27, 2026 •

Copy link
Copy Markdown

The VSETATTR page says the command replies with an error "for improperly specified attribute string". It does not: the string is stored as given, without validation.

Checked against redis/redis at 20bb2cfc5:

$ redis-cli VADD s VALUES 2 1 0 a
1
$ redis-cli VADD s VALUES 2 0 1 b
1
$ redis-cli VSETATTR s a '{broken'
1
$ redis-cli VGETATTR s a
{broken
$ redis-cli VSETATTR s b '{"x":1}'
1
$ redis-cli VSIM s VALUES 2 1 1 FILTER '.x != 5'
b

{broken is not valid JSON in any form, while a quoted string such as "text" would be.

VSETATTR_RedisCommand in modules/vector-sets/vset.c does not parse the attribute, and the module README documents only the 0/1 replies. Elements whose attributes are not valid JSON are treated as not matching by FILTER, as the filtered search page already says.

Now the Return information lists only the integer (RESP2) and boolean (RESP3) replies, and the json argument says the string is stored without validation.

Copilot AI lite review requested due to automatic review settings September 27, 2026 08:01

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

🟡 Changes recommended

The argument text still incorrectly requires valid JSON; remove that requirement while retaining empty-string deletion.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Updates VSETATTR documentation to match runtime behavior.

Changes:

  • Documents storage without JSON validation.
  • Clarifies invalid JSON filtering behavior and RESP2/RESP3 replies.
File Summary
content/​commands/​vsetattr.md Updates argument and return documentation.

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

Comment thread content/commands/vsetattr.md Outdated
@Laurianti

Copy link
Copy Markdown
Author

A note on the choice made here. The page could have been kept and the code aligned to it instead, since an attribute that is not valid JSON is almost always a caller mistake, and today it surfaces only later, when FILTER silently skips the element.

This PR aligns the page to the code because the other sources agree with the code: the module README documents only the 0/1 replies, and the filtered search page states that elements with invalid JSON are treated as not matching without error. Adding validation would also be a behavior change (a VSETATTR that succeeds today would fail), with a decision to take on JSON that is valid but not an object.

If validating the attribute in VSETATTR is the preferred direction, I can open the issue on redis/redis and send the change with tests.

@dwdougherty
dwdougherty self-requested a review September 28, 2026 13:21
@dwdougherty dwdougherty self-assigned this Sep 28, 2026
@dwdougherty dwdougherty added cmds oss Redis Open Source labels Sep 28, 2026

@dwdougherty dwdougherty 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.

Thanks again, @Laurianti. Approved.

It's up to you whether or not you open a ticket on redis/redis.

@dwdougherty
dwdougherty merged commit fc9f4c0 into redis:main Sep 28, 2026
4 checks passed
@Laurianti

Copy link
Copy Markdown
Author

Thanks! I opened redis/redis#15886 for the validation.

EliShteinman added a commit to EliShteinman/docs that referenced this pull request Sep 29, 2026
Documents that VSETATTR stores the attribute string unvalidated and returns no error for it.
EliShteinman added a commit to EliShteinman/docs that referenced this pull request Sep 29, 2026
Documents that VSETATTR stores the attribute string unvalidated and returns no error for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmds oss Redis Open Source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants