Redis test #SF6 error, can't figure out

I’m stuck on Stage #SF6.

I’ve tried using print statements to debug, but none of them appear on the test that crashes.

Here are my logs:

[tester::#SF6] Running tests for Stage #SF6 (Lists - List elements (positive indexes))
[tester::#SF6] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[tester::#SF6] [client] $ redis-cli RPUSH orange mango blueberry grape orange pineapple banana strawberry
[your_program] TEST
[tester::#SF6] [client] ✔︎ Received 7
[tester::#SF6] [client] > LRANGE orange 0 5
[tester::#SF6] [client] ✔︎ Received [
[tester::#SF6] [client]   "mango",
[tester::#SF6] [client]   "blueberry",
[tester::#SF6] [client]   "grape",
[tester::#SF6] [client]   "orange",
[tester::#SF6] [client]   "pineapple",
[tester::#SF6] [client]   "banana"
[tester::#SF6] [client] ]
[tester::#SF6] [client] > LRANGE orange 5 6
[tester::#SF6] [client] ✔︎ Received ["banana", "strawberry"]
[tester::#SF6] [client] > LRANGE orange 0 6
[tester::#SF6] [client] ✔︎ Received [
[tester::#SF6] [client]   "mango",
[tester::#SF6] [client]   "blueberry",
[tester::#SF6] [client]   "grape",
[tester::#SF6] [client]   "orange",
[tester::#SF6] [client]   "pineapple",
[tester::#SF6] [client]   "banana",
[tester::#SF6] [client]   "strawberry"
[tester::#SF6] [client] ]
[tester::#SF6] [client] > LRANGE orange 1 0
[tester::#SF6] [client] ✔︎ Received []
[tester::#SF6] [client] > LRANGE orange 0 14
[tester::#SF6] Received: "" (no content received)
[tester::#SF6]            ^ error
[tester::#SF6] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
[tester::#SF6] Test failed

And here’s a snippet of my code:

if msg_type == "LRANGE":

                set_key = data_array[1]
                start_ind = int(data_array[2])
                end_ind = int(data_array[3])

                if set_key not in data_storage.keys():
                    return_string = "*0\r\n"
                    connection.sendall( return_string.encode() )
                    return
                
                retrieved_list = data_storage[set_key]

                if start_ind>=len(retrieved_list):
                    return_string = "*0\r\n"
                    connection.sendall( return_string.encode() )
                    return

                if end_ind >= len(retrieved_list):
                    end_ind = len(retrieved_list)-1

                if start_ind>end_ind:
                    return_string = "*0\r\n"
                    connection.sendall( return_string.encode() )
                    return


                length_array = (end_ind-start_ind)+1
                
                return_string = "*"+str(length_array)+"\r\n"
                for i in range(start_ind, (end_ind+1) ):
                    length_entry = len( retrieved_list[i].encode() )
                    return_string = return_string + "$"+str(length_entry)+"\r\n"+str(retrieved_list[i])+"\r\n"
                connection.sendall( return_string.encode() )

Here is the code:

Hey @samborsol, looks like the issue was caused by the return statement inside the response function. Since it exits early, it stops proccessing any further requests:

Let me know if you’d like any additional clarification!

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.