redis/go-redis · error
at least one of LibName and LibVer should be set
Error message
at least one of LibName and LibVer should be set
What it means
Error returned by LibraryInfo.Validate (commands.go:354) when neither LibName nor LibVer is set in the LibraryInfo struct passed to CLIENT SETINFO. The Redis CLIENT SETINFO command requires at least one of LIB-NAME or LIB-VER to be provided, so the client rejects a fully empty LibraryInfo before sending anything to the server. Fix: set LibName, LibVer, or both — but not simultaneously, since setting both triggers a separate mutual-exclusion error.
Source
Thrown at commands.go:354
var cmd *StatusCmd
if info.LibName != nil {
libName := fmt.Sprintf("go-redis(%s,%s)", *info.LibName, internal.ReplaceSpaces(runtime.Version()))
cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-NAME", libName)
} else {
cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-VER", *info.LibVer)
}
_ = c(ctx, cmd)
return cmd
}
// Validate checks if only one field in the struct is non-nil.
func (info LibraryInfo) Validate() error {
if info.LibName != nil && info.LibVer != nil {
return errors.New("both LibName and LibVer cannot be set at the same time")
}
if info.LibName == nil && info.LibVer == nil {
return errors.New("at least one of LibName and LibVer should be set")
}
return nil
}
// Hello sets the resp protocol used.
func (c statefulCmdable) Hello(ctx context.Context,
ver int, username, password, clientName string,
) *MapStringInterfaceCmd {
args := make([]interface{}, 0, 7)
args = append(args, "hello", ver)
if password != "" {
if username != "" {
args = append(args, "auth", username, password)
} else {
args = append(args, "auth", "default", password)
}
}
if clientName != "" {View on GitHub (pinned to c5cad058c7)
Solutions
- Populate at least one field, e.g. LibName: redis.StringPtr("myapp").
- Guard the call: only invoke ClientSetInfo when the LibraryInfo value validates.
- Skip the call entirely if you have nothing to report to the server.
Example fix
// before
info := redis.LibraryInfo{}
rdb.ClientSetInfo(ctx, info)
// after
if info.LibName != nil || info.LibVer != nil {
rdb.ClientSetInfo(ctx, info)
} Defensive patterns
Strategy: validation
Validate before calling
func hasAnyField(info redis.LibraryInfo) bool {
return info.LibName != nil || info.LibVer != nil
}
if !hasAnyField(info) { return errors.New("LibraryInfo is empty") } Type guard
func nonEmpty(info redis.LibraryInfo) bool {
return info.LibName != nil || info.LibVer != nil
} Prevention
- Never construct redis.LibraryInfo{} literally without fields.
- Default to LibName: redis.StringPtr(<app name>) in shared helpers.
- Skip the ClientSetInfo call when there is nothing to report.
When it happens
Trigger: Calling ClientSetInfo with redis.LibraryInfo{} (both pointer fields nil).
Common situations: Building LibraryInfo dynamically from variables that may be unset and forgetting to check; copying an options struct where both fields were never populated.
Related errors
- both LibName and LibVer cannot be set at the same time
- redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusi
- redis: CLIENT TRACKING BCAST cannot be combined with OPTIN o
- redis: CLIENT TRACKING PREFIX requires BCAST
- MemoryUsage expects single sample count
AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01).
Data as JSON: /api/errors/4d8d7fe26d9f87a4.
Report an issue: GitHub.