{"record":{"id":"e2993a9c3f52156a","repo":"Tencent/WeKnora","slug":"get-sandbox-binding-w","errorCode":null,"errorMessage":"get sandbox binding: %w","messagePattern":"get sandbox binding: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_binding_redis.go","lineNumber":122,"sourceCode":"\t\tlockLease:         redisLifecycleLockLease,\n\t\tlockRenewInterval: redisLifecycleLockRenewInterval,\n\t}, nil\n}\n\n// Get returns the current binding, or nil when the session is unbound.\nfunc (s *RedisSessionSandboxBindingStore) Get(\n\tctx context.Context,\n\tkey SessionSandboxKey,\n) (*SessionSandboxBinding, error) {\n\tif err := key.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\traw, err := s.client.Get(ctx, s.bindingKey(key)).Bytes()\n\tif errors.Is(err, redis.Nil) {\n\t\treturn nil, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get sandbox binding: %w\", err)\n\t}\n\n\tvar binding SessionSandboxBinding\n\tif err := json.Unmarshal(raw, &binding); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode sandbox binding: %w\", err)\n\t}\n\tif err := binding.Validate(key); err != nil {\n\t\treturn nil, fmt.Errorf(\"validate sandbox binding: %w\", err)\n\t}\n\treturn &binding, nil\n}\n\n// Create stores a validated current-schema binding with SET NX and no\n// expiration.\nfunc (s *RedisSessionSandboxBindingStore) Create(\n\tctx context.Context,\n\tkey SessionSandboxKey,\n\tbinding SessionSandboxBinding,","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_binding_redis.go#L104-L140","documentation":"Get fetches the raw binding JSON from Redis by the binding key. A miss (redis.Nil) returns (nil, nil) by design, but any other Redis error — connection failure, timeout, cluster redirect, auth — is wrapped as \"get sandbox binding: %w\". The caller cannot distinguish store outages from other faults except through the wrapped cause.","triggerScenarios":"Calling Get while Redis is unreachable, the client's dial/auth settings are wrong, a read timeout elapses, or MOVED/CLUSTER errors occur in clustered deployments.","commonSituations":"Redis restart or failover mid-session; wrong REDIS_URL/password in the environment; connection pool exhausted under load; network partition between app and Redis.","solutions":["Inspect the wrapped cause; fix connectivity, credentials, or cluster routing as indicated","Retry Get with short backoff for transient Redis failures (timeouts, pool exhaustion)","Confirm REDIS_URL/TLS/auth env configuration matches the deployed Redis topology","For misses, remember redis.Nil returns (nil, nil) — treat that as 'no binding', not this error"],"exampleFix":"// before\nb, err := store.Get(ctx, key)\nif err != nil { return err }\n// after\nb, err := store.Get(ctx, key)\nif err != nil {\n    if isRedisTransient(err) { return retryGet(ctx, key) }\n    return fmt.Errorf(\"binding lookup: %w\", err)\n}","handlingStrategy":"retry","validationCode":"if err := redisClient.Ping(ctx).Err(); err != nil {\n    return fmt.Errorf(\"redis unreachable: %w\", err)\n}","typeGuard":"func bindingExists(b *sandbox.SessionSandboxBinding, err error) bool {\n    return err == nil && b != nil // (nil, nil) means miss, not error\n}","tryCatchPattern":"b, err := store.Get(ctx, key)\nif err != nil {\n    if isRedisTransient(err) { return retryGet(ctx, key) }\n    return fmt.Errorf(\"binding get: %w\", err)\n}\nif b == nil { return errNoBinding } // redis.Nil miss path","preventionTips":["Distinguish the (nil, nil) miss from errors in callers","Retry transient Redis errors with backoff","Monitor Redis health and pool saturation","Validate REDIS_URL/TLS/auth config in deploy checks"],"tags":["go","redis","network","storage"],"backgroundTag":"redis-connection-error","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}