Fix : Get command buffer handling closes #2979 by watersRand · Pull Request #3197 · redis/node-redis

Description

This PR addresses an inconsistency in the GET command's reply transformation where it could occasionally return a raw Buffer instead of a string.

The Problem: In certain environments (high-concurrency or specific containerized setups), the Redis client would return binary data (Buffers) for keys that were expected to be UTF-8 strings. This required manual Buffer.isBuffer() checks in application code.

The Fix: 1. GET.ts: Updated transformReply to use type-guarding (Buffer.isBuffer). It now explicitly converts Buffer replies to UTF-8 strings, ensuring a consistent return type of string | null and satisfying the linter.
2. GET.spec.ts: Updated the test suite to handle Buffer arguments correctly in transformArguments.

Related to the reported "random buffer" behavior during key retrieval in #2979

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Low Risk
Test-only changes that broaden GET coverage across key types and common value scenarios; no production logic is modified.

Overview
Improves the GET command test suite by expanding transformArguments cases (including Buffer keys) and adding broader transformReply assertions for missing keys, empty strings, overwrites, and values set from Buffer inputs to ensure consistent string returns.

Written by Cursor Bugbot for commit 2d27e7d. This will update automatically on new commits. Configure here.