Tencent/WeKnora · error

WEKNORA_REDIS_NAMESPACE must not contain braces

Error message

WEKNORA_REDIS_NAMESPACE must not contain braces

What it means

validateRedisNamespace rejects a WEKNORA_REDIS_NAMESPACE containing '{' or '}'. Braces are reserved by Redis Cluster key hashing ({...} defines hash tags), so allowing them in the namespace could break key distribution; NewRedisSessionSandboxBindingStore refuses to start with such a namespace.

Source

Thrown at internal/sandbox/session_binding_redis.go:405

func (s *RedisSessionSandboxBindingStore) lockKey(key SessionSandboxKey) string {
	// Keep the historical suffix used by the saved multi-node Cube
	// implementation so rolling upgrades serialize on the same lock.
	return "weknora:sandbox:session:{" + s.hashTag(key) + "}:create-lock"
}

func (s *RedisSessionSandboxBindingStore) hashTag(key SessionSandboxKey) string {
	return fmt.Sprintf("%s:%d:%s", s.namespace, key.TenantID, key.SessionID)
}

var (
	_ tenantBindingScanner  = (*RedisSessionSandboxBindingStore)(nil)
	_ sessionTurnLeaseStore = (*RedisSessionSandboxBindingStore)(nil)
)

func validateRedisNamespace(namespace string) error {
	if strings.ContainsAny(namespace, "{}") {
		return errors.New("WEKNORA_REDIS_NAMESPACE must not contain braces")
	}
	for _, r := range namespace {
		if unicode.IsControl(r) {
			return errors.New("WEKNORA_REDIS_NAMESPACE must not contain control characters")
		}
	}
	return nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Remove braces from WEKNORA_REDIS_NAMESPACE (use plain prefixes like 'weknora:sandbox:').
  2. Expand any template placeholders in deployment config so a literal '{...}' never reaches the env var.
  3. Validate the value at deploy time (echo "$WEKNORA_REDIS_NAMESPACE") before startup.

Example fix

// before (deployment env)
WEKNORA_REDIS_NAMESPACE=weknora:{tenant}:sandbox
// after
WEKNORA_REDIS_NAMESPACE=weknora.sandbox
Defensive patterns

Strategy: validation

Validate before calling

if ns := os.Getenv("WEKNORA_REDIS_NAMESPACE"); strings.ContainsAny(ns, "{}") {
    return fmt.Errorf("WEKNORA_REDIS_NAMESPACE must not contain braces: %q", ns)
}

Try / catch

store, err := sandbox.NewRedisSessionSandboxBindingStore(client, ns)
if err != nil {
    return fmt.Errorf("redis namespace %q rejected: %w", ns, err)
}

Prevention

When it happens

Trigger: Starting the service with WEKNORA_REDIS_NAMESPACE containing '{' or '}' in the environment, failing NewRedisSessionSandboxBindingStore.

Common situations: Operator copies a Redis Cluster hash-tagged key pattern into the namespace env var; template placeholders like '{tenant}' left unexpanded in deployment config.

Related errors


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