Skip to content

Commit a6e45f8

Browse files
committed
Fix HELLO output. "proto" field was sent as BulkString which broke clients like redis-py in RESP3 mode.
1 parent 8919120 commit a6e45f8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

libs/server/Resp/BasicCommands.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,8 @@ void ProcessHelloCommand(byte? respProtocolVersion, ReadOnlySpan<byte> username,
15691569
("server", "redis"),
15701570
("version", storeWrapper.redisProtocolVersion),
15711571
("garnet_version", storeWrapper.version),
1572-
("proto", this.respProtocolVersion),
1573-
("id", 63),
1572+
("proto", (long)this.respProtocolVersion),
1573+
("id", Id),
15741574
("mode", storeWrapper.serverOptions.EnableCluster ? "cluster" : "standalone"),
15751575
("role", storeWrapper.serverOptions.EnableCluster && storeWrapper.clusterProvider.IsReplica() ? "replica" : "master"),
15761576
];
@@ -1580,9 +1580,9 @@ void ProcessHelloCommand(byte? respProtocolVersion, ReadOnlySpan<byte> username,
15801580
{
15811581
while (!RespWriteUtils.TryWriteAsciiBulkString(helloResult[i].Item1, ref dcurr, dend))
15821582
SendAndReset();
1583-
if (helloResult[i].Item2 is int intValue)
1583+
if (helloResult[i].Item2 is long value)
15841584
{
1585-
while (!RespWriteUtils.TryWriteInt32(intValue, ref dcurr, dend))
1585+
while (!RespWriteUtils.TryWriteInt64(value, ref dcurr, dend))
15861586
SendAndReset();
15871587
}
15881588
else
@@ -1593,7 +1593,7 @@ void ProcessHelloCommand(byte? respProtocolVersion, ReadOnlySpan<byte> username,
15931593
}
15941594
while (!RespWriteUtils.TryWriteAsciiBulkString("modules", ref dcurr, dend))
15951595
SendAndReset();
1596-
while (!RespWriteUtils.TryWriteArrayLength(0, ref dcurr, dend))
1596+
while (!RespWriteUtils.TryWriteEmptyArray(ref dcurr, dend))
15971597
SendAndReset();
15981598
}
15991599

test/Garnet.test/RespTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,12 +3907,12 @@ public void AsyncTest1()
39073907
{
39083908
var db = redis.GetDatabase(0);
39093909

3910-
int keyCount = 5;
3911-
int valLen = 256;
3912-
int keyLen = 8;
3910+
var keyCount = 5;
3911+
var valLen = 256;
3912+
var keyLen = 8;
39133913

39143914
List<Tuple<string, string>> data = [];
3915-
for (int i = 0; i < keyCount; i++)
3915+
for (var i = 0; i < keyCount; i++)
39163916
{
39173917
lastKey = GetRandomString(keyLen);
39183918
lastValue = GetRandomString(valLen);
@@ -3932,7 +3932,7 @@ public void AsyncTest1()
39323932

39333933
var expectedNewlineCount = 30; // 30 '\n' characters expected in response
39343934
var response = lightClientRequest.Execute($"hello 3", expectedNewlineCount);
3935-
ClassicAssert.IsTrue(response.Length is > 180 and < 190);
3935+
ClassicAssert.IsTrue(response.Length is > 175 and < 190);
39363936

39373937
// Switch to byte counting in response
39383938
lightClientRequest.countResponseType = CountResponseType.Bytes;

0 commit comments

Comments
 (0)