{"id":"fb0728b427bff869","repo":"go-redis/redis","slug":"expected-digit-or-crlf-got-q","errorCode":null,"errorMessage":"expected digit or CRLF, got %q","messagePattern":"expected digit or CRLF, got %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/proto/reader.go","lineNumber":271,"sourceCode":"\tfor i := pos; i < len(buf)-1; i++ {\n\t\tif buf[i] == '\\r' && buf[i+1] == '\\n' {\n\t\t\treturn util.BytesToString(buf[pos:i]), true, nil\n\t\t}\n\t}\n\treturn \"\", false, nil\n}\n\n// skipDigitsThenCRLF advances past zero-or-more ASCII digits and the\n// terminating \"\\r\\n\" starting at offset start in buf. It returns the position\n// after the \"\\r\\n\" and true on success; (pos, false, nil) if buf is too\n// short; or an error if a non-digit non-CR byte is encountered before the CRLF.\nfunc skipDigitsThenCRLF(buf []byte, start int) (int, bool, error) {\n\tfor pos := start; pos < len(buf)-1; pos++ {\n\t\tif buf[pos] == '\\r' && buf[pos+1] == '\\n' {\n\t\t\treturn pos + 2, true, nil\n\t\t}\n\t\tif buf[pos] < '0' || buf[pos] > '9' {\n\t\t\treturn pos, false, fmt.Errorf(\"expected digit or CRLF, got %q\", buf[pos])\n\t\t}\n\t}\n\treturn len(buf), false, nil\n}\n\n// ReadLine Return a valid reply, it will check the protocol or redis error,\n// and discard the attribute type.\nfunc (r *Reader) ReadLine() ([]byte, error) {\n\tline, err := r.readLine()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch line[0] {\n\tcase RespError:\n\t\treturn nil, ParseErrorReply(line)\n\tcase RespNil:\n\t\treturn nil, Nil\n\tcase RespBlobError:","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/proto/reader.go#L253-L289","documentation":"Error \"expected digit or CRLF, got %q\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/proto/reader.go:271 when the library encounters an invalid state.","commonSituations":"Validate every frame strictly and drop the connection on the first malformed byte.","solutions":["Reconnect to resynchronize; the stream contained an unexpected byte where a digit/CRLF was expected","Check for non-Redis traffic on the connection"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}