Skip to content

fix: handle Redis "unauthenticated multibulk length" error with re-auth retry - #49

Merged
johnlanni merged 1 commit into
higress-group:mainfrom
sjtuzbk:fix/redis-unauthenticated-multibulk-retry
May 14, 2026
Merged

fix: handle Redis "unauthenticated multibulk length" error with re-auth retry#49
johnlanni merged 1 commit into
higress-group:mainfrom
sjtuzbk:fix/redis-unauthenticated-multibulk-retry

Conversation

@sjtuzbk

@sjtuzbk sjtuzbk commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Broadens the Redis authentication error detection in redisCallInternal to also match "unauthenticated" keyword, in addition to the existing "NOAUTH Authentication required" check.
  • This fixes a bug where Redis connections silently lose AUTH state after Envoy cluster config updates (e.g. upstreamIdleTimeout changes), causing ERR Protocol error: unauthenticated multibulk length errors that were not caught by the existing retry logic.

Background

When Envoy gateway configuration changes (such as updating upstreamIdleTimeout which modifies HttpProtocolOptions.common_http_protocol_options.idle_timeout on all clusters), the cluster connection pool may be drained and recreated. The new TCP connections to Redis lack the AUTH state that was established during RedisInit().

Redis 6+ has a security feature where it refuses to parse RESP commands from unauthenticated clients, returning ERR Protocol error: unauthenticated multibulk length instead of the more common NOAUTH Authentication required. The existing retry logic in redis_wrapper.go only checked for the latter, so this error variant bypassed the automatic re-authentication mechanism.

Changes

In pkg/wrapper/redis_wrapper.go, the error matching condition is changed from:

if bytes.Contains([]byte(errMsg), []byte("NOAUTH Authentication required")) {

to:

if bytes.Contains([]byte(errMsg), []byte("NOAUTH Authentication required")) ||
    bytes.Contains([]byte(errMsg), []byte("unauthenticated")) {

Test plan

  • Verify that NOAUTH Authentication required errors still trigger re-auth retry (existing behavior preserved)
  • Verify that ERR Protocol error: unauthenticated multibulk length errors now also trigger re-auth retry
  • Verify that unrelated Redis errors are not affected by this change

Made with Cursor

…th retry

When Envoy cluster configuration changes (e.g. upstreamIdleTimeout update),
the connection pool may be drained and recreated. New TCP connections to
Redis lack the AUTH state that was established during RedisInit().

Redis 6+ returns "ERR Protocol error: unauthenticated multibulk length"
instead of "NOAUTH Authentication required" when an unauthenticated client
sends a RESP multibulk command. The existing retry logic only matched
"NOAUTH Authentication required", so this error variant was not caught
and not retried.

This commit broadens the error detection to also match "unauthenticated",
covering both error variants and enabling automatic re-authentication
and retry.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: zhaobingkun.zbk <zhaobingkun.zbk@alibaba-inc.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sjtuzbk
sjtuzbk force-pushed the fix/redis-unauthenticated-multibulk-retry branch from 8652faa to 259c3e4 Compare May 14, 2026 03:00

@johnlanni johnlanni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnlanni
johnlanni merged commit d677f6c into higress-group:main May 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants