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_4 (already cloned)
- Base commit: 07a6271b76f6986f30064d51113838d486f0f2c6
- Task ID: juspay__hyperswitch-8906
- Version: v1.116.0
TASK DESCRIPTION: Bug: Improve UCS connector configuration format for better type safety and usability
Problem Statement
The current unified connector service (UCS) configuration uses an array format for specifying connectors that should use UCS only. This approach has several limitations:
Current Issues
- Type Safety: The current
Vec<String>approach allows invalid connector names to be specified without compile-time validation - Configuration Verbosity: Array format in TOML files is more verbose and harder to read/maintain
- Runtime Validation: Invalid connector names are only caught at runtime when the configuration is parsed
- Inconsistent Format: Different from other comma-separated configuration patterns used elsewhere in the codebase
Current Configuration Format
[grpc_client.unified_connector_service] ucs_only_connectors = [ "razorpay", "phonepe", "paytm", "cashfree", ]Proposed Solution
Refactor the configuration to use a comma-separated string format with type-safe parsing:
Benefits
- Type Safety: Use
HashSet<Connector>with enum validation to prevent invalid connector names - Cleaner Configuration: More concise and readable comma-separated format
- Better Error Handling: Custom deserializer with detailed error messages for invalid configurations
- Consistency: Aligns with other comma-separated configuration patterns in the codebase
- Performance: HashSet provides O(1) lookup time for connector validation
Proposed Configuration Format
[grpc_client.unified_connector_service] ucs_only_connectors = "paytm, phonepe, razorpay, cashfree"Implementation Requirements
- Custom Deserializer: Implement a generic deserializer for comma-separated strings to typed HashSets
- Type Safety: Use
Connectorenum instead of raw strings
Assistant
I'll help you refactor the UCS connector configuration to use a comma-separated string format for better type safety and usability. Let me start by exploring the codebase to understand the current implementation and identify the files that need to be modified.
First, let me examine the current configuration structure and locate the relevant files.
Assistant
(no content)
Assistant
Let me examine the specific files that need to be modified to implement this refactoring. I'll start by reading the configuration struct and connector enums.
Assistant
Now let me look at the connector enum definitions to understand what connectors are available:
Assistant
Now let me check the current configuration files to see how they're currently set up:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me check the config.example.toml file to see how it's set up:
Assistant
Let me also look at the deployment config files:
Assistant
Let me also check for any existing utils.rs files that might contain helper functions:
Assistant
Let me check the router code to understand how the UCS connectors are used:
Assistant
Now I have a good understanding of the current implementation. Let me check if there are any existing tests for this functionality to understand how to approach testing:
Assistant
Let me now plan the implementation with clear todos:
Assistant
I'll now implement the changes to refactor the UCS connector configuration from array format to comma-separated string format with type safety.
First, let me create the utility module with the custom deserializer:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.