fivenines

Practice / target 80%

RESP Protocol Parser Practice

01

Given `*2\r\n$3\r\nGET\r\n$4\r\nna`, should the parser return an error or wait for more bytes? What fact makes the answer clear?

intro

Scenario

Your parser's buffer currently holds the bytes `*2\r\n$3\r\nGET\r\n$4\r\nna` received from one socket read.

02

Why is `SET note "a b"` unsafe to parse by splitting on spaces, even before considering binary data?

intro

Scenario

A teammate prototypes command parsing with `input.split(" ")` and asks why that cannot ship.

03

A buffer contains two complete RESP arrays and half of a third. What should `consumed` represent after the first parse call?

applied

Scenario

Your parse function takes a buffer and returns parsed values plus a count of bytes it consumed.

04

Which layer should reject a nested array used as a command argument: the RESP parser or command dispatch? Defend one design.

applied

Scenario

A client sends a syntactically valid RESP array in which one element is itself a nested array, then uses it as a command.

05

How does null bulk string output differ from an empty bulk string output on the wire?

advanced

Scenario

You are implementing GET's reply path and must encode both a missing key and a key holding an empty string.