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
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
Previously, lineage context was being cached with environment-specific prefixes (
public_in V1 andpublic_v2_in V2), leading to inconsistencies in user experience during login/logout flows across deployments. Switching to a consistent global prefix resolves this by isolating user lineage data under a unified Redis namespace.How did you test it?
Use test cases from this PR: https://github.com/juspay/hyperswitch/pull/7871
The key should now be in the format of global:LINEAGE_CONTEXT_<user_id>
Checklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_9/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
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:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →