You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_9 (already cloned)
- Base commit: 54e910582fac9bd6fe300a9a96926adf5123403e
- Task ID: juspay__hyperswitch-7891
- Version: v1.113.0
TASK DESCRIPTION: Bug: Standardize Redis Key Prefix for User Lineage Context
Currently, the lineage context is cached in Redis using tenant-specific key prefixes (public_, public_v2_). This causes inconsistencies across V1 and V2 environments — especially during login/logout flows — as lineage context data becomes deployment-specific.
Need to introduce a new Redis connection helper that overrides the prefix with the global value from config (global).
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR updates the lineage context Redis caching logic to use a dedicated global Redis key prefix (
global) instead of the default tenant-scoped prefixes (public_,public_v2_), causing inconsistencies between deployments (i.e., v1 and v2).Introduced a new helper:
get_redis_connection_for_global_tenant- Fetches Redis connection with
key_prefixset toglobal. - Updated lineage context caching (
get_lineage_context_from_cache,set_lineage_context_in_cache) to use the global Redis connection
This will enable https://github.com/juspay/hyperswitch/pull/7871 to work with both v1 and v2 merchant accounts.
The redis-key should now be in the format of global:LINEAGE_CONTEXT_<user_id>
Additional Changes
- This PR modifies the API contract
Assistant
I'll help you implement the Redis key prefix standardization for user lineage context in the hyperswitch repository. Let me start by creating a plan and exploring the codebase to understand the current implementation.
Assistant
Let me first explore the codebase to understand how Redis is currently implemented and where lineage context caching is handled.
Assistant
(no content)
Assistant
Let me search more specifically for lineage context related code and Redis connection helpers to understand the current implementation better.
Assistant
Let me search for Redis connection helpers and key prefix related code more specifically.
Assistant
Let me look at the key Redis files to understand how connections are managed and how keys are prefixed.
Assistant
(no content)
Assistant
Let me check the storage_impl/src/redis/cache.rs file to understand how caching works with keys:
Assistant
Let me search for where lineage context is actually used to better understand the issue.
Assistant
Let me look at how the Redis connection is used in the user context and how caching works:
Assistant
Let me check the constants for the lineage context prefix to understand how it's currently used:
Assistant
Now I need to look at how the Redis connection is established to understand how to create a new connection helper for global tenant. Let me also check the Redis connection code to understand how key prefixes work:
Assistant
Now I understand how the Redis connections work. Let me update my todo list and implement the solution.
First, let me update the task status:
Assistant
Looking at the codebase, I now understand what needs to be done:
- The Redis connection pool already has a
clone()method that allows creating new connections with a different prefix - We need to add a new helper function in
redis_interface/src/lib.rsto create a Redis connection with the "global" prefix - We need to update the lineage context caching functions in
utils/user.rsto use this new global connection helper
Let me first implement the new helper function in RedisConnectionPool:
- The Redis connection pool already has a
Assistant
Let me look at the exact content around that section to make the correct edit:
Assistant
(no content)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.