diff --git a/src/debug.c b/src/debug.c index 5d32ef0bc..4f0e37777 100644 --- a/src/debug.c +++ b/src/debug.c @@ -795,6 +795,10 @@ NULL * also have a normal reply type after the attribute. */ addReplyBulkCString(c,"Some real reply following the attribute"); } else if (!strcasecmp(name,"push")) { + if (c->resp < 3) { + addReplyError(c,"RESP2 is not supported by this command"); + return; + } addReplyPushLen(c,2); addReplyBulkCString(c,"server-cpu-usage"); addReplyLongLong(c,42); diff --git a/src/module.c b/src/module.c index 727da4783..b1a40221f 100644 --- a/src/module.c +++ b/src/module.c @@ -2890,8 +2890,11 @@ void RM_ReplySetSetLength(RedisModuleCtx *ctx, long len) { } /* Very similar to RedisModule_ReplySetMapLength - * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ + * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. + * + * Must not be called if RM_ReplyWithAttribute returned an error. */ void RM_ReplySetAttributeLength(RedisModuleCtx *ctx, long len) { + if (ctx->client->resp == 2) return; moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ATTRIBUTE); }