Repository: microsoft/garnet
File: libs/server/Resp/Objects/ListCommands.cs (C#)

Code before:
            bool result = false;

            if (count != 4)
            {
                return AbortWithWrongNumberOfArguments("LMOVE", count);
            }
            else
            {
                ArgSlice sourceKey = default, destinationKey = default, param1 = default, param2 = default;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref sourceKey.ptr, ref sourceKey.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref destinationKey.ptr, ref destinationKey.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref param1.ptr, ref param1.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref param2.ptr, ref param2.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                OperationDirection sourceDirection = GetOperationDirection(param1);
                OperationDirection destinationDirection = GetOperationDirection(param2);
                if (sourceDirection == OperationDirection.Unknown || destinationDirection == OperationDirection.Unknown)
                {
                    return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
                }

                result = ListMove(count, sourceKey, destinationKey, sourceDirection, destinationDirection, out var node, ref storageApi);
                if (node != null)
                {
                    while (!RespWriteUtils.WriteBulkString(node, ref dcurr, dend))
                        SendAndReset();
                }
                else
                {
                    while (!RespWriteUtils.WriteNull(ref dcurr, dend))
                        SendAndReset();
                }
            }

            // Move input head, write result to output
            readHead = (int)(ptr - recvBufferPtr);
            return result;
        }

        /// <summary>
        /// RPOPLPUSH source destination
        /// </summary>
        /// <param name="count"></param>

Review comment (suggestion):
Thanks for adding this fix! If you have a couple of minutes, would you please add a couple of test cases to check that the correct error is raised? Probably best to add in the CanUseLMoveGC method in RespListTest.cs
Appreciate it!

Code after:

            if (count != 4)
            {
                return AbortWithWrongNumberOfArguments("LMOVE", count);
            }
            else
            {
                ArgSlice sourceKey = default, destinationKey = default, param1 = default, param2 = default;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref sourceKey.ptr, ref sourceKey.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref destinationKey.ptr, ref destinationKey.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref param1.ptr, ref param1.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref param2.ptr, ref param2.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                OperationDirection sourceDirection = GetOperationDirection(param1);
                OperationDirection destinationDirection = GetOperationDirection(param2);
                if (sourceDirection == OperationDirection.Unknown || destinationDirection == OperationDirection.Unknown)
                {
                    return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
                }

                result = ListMove(count, sourceKey, destinationKey, sourceDirection, destinationDirection, out var node, ref storageApi);
                if (node != null)
                {
                    while (!RespWriteUtils.WriteBulkString(node, ref dcurr, dend))
                        SendAndReset();
                }
                else
                {
                    while (!RespWriteUtils.WriteNull(ref dcurr, dend))
                        SendAndReset();
                }
            }

            // Move input head, write result to output
            readHead = (int)(ptr - recvBufferPtr);
            return result;
        }

        /// <summary>
        /// RPOPLPUSH source destination
        /// </summary>
        /// <param name="count"></param>
        /// <param name="ptr"></param>