Repository navigation
Fix RedisModule_CallReplyAttribute returning NULL on unparsed reply - #16368
ArianPashae wants to merge 2 commits into
Conversation
…edis#16334) When RedisModule_CallReplyAttribute() was called on a RedisModuleCallReply before any other accessor (such as RedisModule_CallReplyType()), it returned NULL even when the RESP3 reply contained an attribute. This occurred because callReplyGetAttribute() returned rep->attribute directly without invoking callReplyParse(rep) first. In addition: - callReplyGetAttributeElement() checked rep->type != REDISMODULE_REPLY_MAP instead of REDISMODULE_REPLY_ATTRIBUTE, which caused element lookups on attribute replies to fail with C_ERR. - callReplyIsResp3() checked flags without ensuring lazy parsing had run. - Enabled and updated test.callresp3attribute in tests/modules/basics.c to verify accessing attributes directly on an unparsed reply and retrieving attribute elements. Fixes redis#16334 Signed-off-by: ArianPashae <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 303b386352
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| T("test.callresp3map",""); | ||
| if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail; | ||
|
|
||
| T("test.callresp3attribute",""); |
There was a problem hiding this comment.
Preserve auto-memory ownership for attribute test strings
With leak detection enabled, this newly enabled subtest fails at shutdown because the three strings created by TestMatchReply() for the attribute key and nested values are never freed. callReplyAttribute() assigns the attribute's private_data only after callReplyParseCollection() has copied its initial NULL value into the children, so RedisModule_CreateStringFromCallReply() bypasses automatic-memory tracking for those strings. A single test.basics run under LeakSanitizer reports 83 leaked bytes in three allocations. Initialize the attribute's context before parsing its collection, or explicitly free these temporary strings, before adding this test to the standard run.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 303b386. Configure here.
Signed-off-by: ArianPashae <[email protected]>

When
RedisModule_CallReplyAttribute()is called on aRedisModuleCallReplybefore any other accessor (such asRedisModule_CallReplyType()), it returns NULL even when the RESP3 reply contains an attribute. This happens becausecallReplyGetAttribute()returnedrep->attributedirectly without runningcallReplyParse(rep)first.In addition:
callReplyGetAttributeElement()checkedrep->type != REDISMODULE_REPLY_MAPinstead ofREDISMODULE_REPLY_ATTRIBUTE, which caused element lookups on attribute replies to fail withC_ERR.callReplyIsResp3()returned flags without ensuring lazy parsing had run, which could cause RESP3 replies to be improperly accepted for RESP2 clients inRM_ReplyWithCallReply().test.callresp3attributeintests/modules/basics.cto verify accessing attributes directly on an unparsed reply and retrieving attribute elements.Fixes #16334
Note
Low Risk
Targeted parser/API fixes in module reply handling with added regression tests; no auth or persistence changes.
Overview
Fixes lazy-parsing gaps in the CallReply API used by
RedisModule_Callso RESP3 attribute handling works when callers touch attributes before other accessors.callReplyGetAttributeandcallReplyIsResp3now null-check and callcallReplyParsebefore reading state, so unparsed replies no longer return a missing attribute or misreport non-RESP3.callReplyGetAttributeElementvalidatesREDISMODULE_REPLY_ATTRIBUTEinstead of map type. Attribute sub-replies inheritprivate_databefore collection parsing.Module tests
test.callresp3attributeare reordered to probe attribute-first access, element lookup, and string creation; the case is wired into thetest.basicssuite.Reviewed by Cursor Bugbot for commit 5ee4217. Bugbot is set up for automated code reviews on this repo. Configure here.