fix: use redis hset mapping for scoped state - #265
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
Coverage ? 87.85411%
==========================================
Files ? 482
Lines ? 45184
Branches ? 0
==========================================
Hits ? 39696
Misses ? 5488
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AI Code Review我已对整个 PR 有完整理解。 现在评估核心改动。生产 唯一要核实的风险点: 我已有结论,输出 review。 发现的问题未发现明显阻塞问题。本次 PR 将
|
|
已按 review 建议更新:
重新验证:
关于 replay backend 的 |
AI Code Review我已经了解足够的信息。让我来整理一下审查结果。 发现的问题🚨 Critical未发现 Critical 级别问题。
|
|
已按最新 review 继续修改:
验证:
|
AI Code Review发现的问题
|
背景
这是 #89 的后续优化。上一次 PR #176 关闭后,主线已经合入了新的 replay harness 实现;本 PR 不再重复提交完整 harness,而是针对后续 Redis 集成验证中暴露出的 scoped state 写入问题做小范围修复。
同时也回应本 PR 中的 review/comment:
RedisClusterStorage.__init__默认decode_responses=True,但普通RedisStorage不默认;因此 replay backend 对 standalone Redis 显式设置decode_responses=True,用于保证真实 Redis 返回字符串,避免跨后端比较时出现bytes/str非业务差异。改进内容
RedisSessionService中 app/user scoped state 的 Redis hash 写入从位置参数形式改为hset(..., mapping=...),兼容真实redis-py的标准调用语义。command.args=(key,),因此EXPIRE_METHOD中依赖command.args[0]的 TTL 刷新逻辑不受影响。test_redis_session_service.py中的 Redis mock,支持mapping写入路径。int/float/str写入后按字符串读回;bool与真实redis-py一样抛DataError。tests/sessions/replay/backends.py的 standalone Redis replay backend 中显式启用decode_responses=True,降低 Redis 集成测试中的序列化噪声。测试
pytest tests/sessions/test_redis_session_service.py -qpytest tests/sessions/test_replay_consistency.py tests/sessions/test_replay_injections.py tests/sessions/test_replay_unit.py -qTRPC_REPLAY_REDIS_URL=redis://localhost:6379/0 pytest tests/sessions/test_replay_consistency.py tests/sessions/test_replay_injections.py tests/sessions/test_replay_unit.py -q