memcache-async icon indicating copy to clipboard operation
memcache-async copied to clipboard

Only match ERROR at start of response line, not within content

Open MatthewCline-git opened this issue 1 year ago • 1 comments

When parsing responses from the memcached server, we incorrectly interpreted any response containing "ERROR" as an error response. However, according to the memcached protocol specification, error responses must START with specific tokens:

Each command sent by a client may be answered with an error string from the server. These error strings come in three types:

  • "ERROR\r\n"
  • "CLIENT_ERROR \r\n"
  • "SERVER_ERROR \r\n"

This PR fixes the bug by checking if the response starts with an error token rather than just containing it. Added test cases verify correct handling of:

  • Responses starting with "ERROR"
  • Responses containing but not starting with "ERROR"
  • CLIENT_ERROR responses
  • SERVER_ERROR responses

Fixes potential issues where valid responses containing "ERROR" in the content would be incorrectly treated as errors.

MatthewCline-git avatar Jan 13 '25 15:01 MatthewCline-git

@vavrusa I wanted to check if there's anything I can do to help move this PR forward. I'm happy to make any requested changes or provide additional context if needed. Thanks for your time!

MatthewCline-git avatar Feb 12 '25 02:02 MatthewCline-git

LGTM, thanks!

vavrusa avatar Mar 12 '25 03:03 vavrusa