Tencent/WeKnora · error

redis client is required

Error message

redis client is required

What it means

Argument guard raised by redislock.Release when the client parameter is nil — Release was called without a usable Redis client, so the release script cannot run. Programming/initialization error rather than a runtime Redis failure.

Solutions

  1. Initialize and pass the Redis UniversalClient before calling Release
  2. Fix the DI/initialization order so the lock helper receives the client
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/common/redislock/token_lock.go:115 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/e87cb11803cd2cb1. Report an issue: GitHub.

Appendix: source

Thrown at internal/common/redislock/token_lock.go:115

		case <-ctx.Done():
			if !timer.Stop() {
				<-timer.C
			}
			return ctx.Err()
		case <-timer.C:
		}
	}
}

// Release deletes the lock only if token still owns it.
func Release(
	ctx context.Context,
	client redis.UniversalClient,
	key string,
	token string,
) (bool, error) {
	if client == nil {
		return false, errors.New("redis client is required")
	}
	if key == "" || token == "" {
		return false, errors.New("redis lock key and token are required")
	}
	released, err := releaseScript.Run(ctx, client, []string{key}, token).Int64()
	if err != nil {
		return false, fmt.Errorf("release redis lock %q: %w", key, err)
	}
	return released != 0, nil
}

// Renew extends the lease only if token still owns the lock.
func Renew(
	ctx context.Context,
	client redis.UniversalClient,
	key string,
	token string,
	lease time.Duration,

View on GitHub (pinned to 988cbb0330)