go-redis/redis · error

redis: invalid push notification name length %q: %w

Error message

redis: invalid push notification name length %q: %w

What it means

Error "redis: invalid push notification name length %q: %w" thrown in go-redis/redis.

Source

Thrown at internal/proto/reader.go:236

	}
	pos++

	if typeOfName == RespString {
		// Read "$M\r\n" then the M-byte name.
		lenStart := pos
		next, ok, err := skipDigitsThenCRLF(buf, pos)
		if err != nil {
			return "", false, fmt.Errorf("redis: can't parse push notification name length: %w", err)
		}
		if !ok {
			return "", false, nil
		}
		if next-2 == lenStart {
			return "", false, fmt.Errorf("redis: empty push notification name length")
		}
		nameLen, err := util.Atoi(buf[lenStart : next-2])
		if err != nil {
			return "", false, fmt.Errorf("redis: invalid push notification name length %q: %w", buf[lenStart:next-2], err)
		}
		if nameLen < 0 {
			return "", false, fmt.Errorf("redis: negative push notification name length: %d", nameLen)
		}
		// Compare against the remaining bytes instead of computing
		// next+nameLen: a hugely advertised length on malformed input could
		// overflow int, wrap negative, slip past an "end > len(buf)" guard and
		// panic the slice below. next <= len(buf) here, so the subtraction is
		// safe.
		if nameLen > len(buf)-next {
			return "", false, nil
		}
		return util.BytesToString(buf[next : next+nameLen]), true, nil
	}

	// RespStatus: scan for the terminating CRLF.
	for i := pos; i < len(buf)-1; i++ {
		if buf[i] == '\r' && buf[i+1] == '\n' {

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Reconnect; the length field quoted in the error is invalid per protocol
  2. Check middleboxes that may alter payloads

When it happens

Trigger: Thrown at internal/proto/reader.go:236 when the library encounters an invalid state.

Common situations: Fail-fast on invalid frame lengths to trigger pool replacement.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/6371050a11c9b316.json. Report an issue: GitHub.