Repository: juspay/hyperswitch
File: crates/router/src/core/unified_connector_service.rs (Rust)

Code before:
        }
    };

    router_env::logger::info!(
        "Payment gateway system decision: {:?} - merchant_id={}, connector={}, payment_method={}, flow={}",
        decision,
        merchant_id,
        connector_name,
        payment_method,
        flow_name
    );

    // Log proxy configuration when overrides are used
    if rollout_result.proxy_override.is_some() || shadow_rollout_result.proxy_override.is_some() {
        router_env::logger::info!("Using updated SessionState with proxy configuration overrides");
    }

    Ok((decision, updated_state))
}

/// Creates a new SessionState with proxy configuration updated from the override
fn create_updated_session_state_with_proxy(
    state: &SessionState,
    proxy_override: &ProxyOverride,
) -> SessionState {
    let mut updated_state = state.clone();

    // Update the proxy configuration with overrides
    let updated_proxy = hyperswitch_interfaces::types::Proxy {
        http_url: proxy_override
            .http_url
            .clone()
            .or(state.conf.proxy.http_url.clone()),
        https_url: proxy_override
            .https_url
            .clone()
            .or(state.conf.proxy.https_url.clone()),
        idle_pool_connection_timeout: state.conf.proxy.idle_pool_connection_timeout,
        bypass_proxy_hosts: state.conf.proxy.bypass_proxy_hosts.clone(),
        mitm_ca_certificate: state.conf.proxy.mitm_ca_certificate.clone(),
        mitm_enabled: state.conf.proxy.mitm_enabled,
    };

    // Create updated configuration
    let mut updated_conf = (*state.conf).clone();
    updated_conf.proxy = updated_proxy;
    updated_state.conf = std::sync::Arc::new(updated_conf);

    updated_state
}


Review comment (suggestion):
```suggestion
    let mut updated_state = state;
```

Code after:
            ShadowRolloutAvailability::NotAvailable,
        ) => Ok((GatewaySystem::Direct, ExecutionPath::Direct)),

        // Case 3: DirectConnector previously used UCS, but now switching back to Direct (no shadow)
        // Migration scenario: UCS was used before, but now we're reverting to Direct
        (
            ConnectorIntegrationType::DirectConnector,
            Some(GatewaySystem::UnifiedConnectorService),
            ShadowRolloutAvailability::NotAvailable,
        ) => Ok((GatewaySystem::Direct, ExecutionPath::Direct)),

        // Case 4: UcsConnector configuration, but previously used Direct gateway (no shadow)
        // Maintain Direct for backward compatibility - don't switch mid-transaction
        (
            ConnectorIntegrationType::UcsConnector,
            Some(GatewaySystem::Direct),
            ShadowRolloutAvailability::NotAvailable,
        ) => Ok((GatewaySystem::Direct, ExecutionPath::Direct)),

        // Case 5: DirectConnector with no previous gateway, shadow rollout enabled
        // Use Direct as primary, but also execute UCS in shadow mode for comparison
        (
            ConnectorIntegrationType::DirectConnector,
            None,
            ShadowRolloutAvailability::IsAvailable,
        ) => Ok((
            GatewaySystem::Direct,
            ExecutionPath::ShadowUnifiedConnectorService,
        )),

        // Case 6: DirectConnector previously used Direct, shadow rollout enabled
        // Continue with Direct as primary, execute UCS in shadow mode for testing
        (
            ConnectorIntegrationType::DirectConnector,
            Some(GatewaySystem::Direct),
            ShadowRolloutAvailability::IsAvailable,
        ) => Ok((
            GatewaySystem::Direct,
            ExecutionPath::ShadowUnifiedConnectorService,
        )),

        // Case 7: DirectConnector previously used UCS, shadow rollout enabled
        // Revert to Direct as primary, but keep UCS in shadow mode for comparison
        (
            ConnectorIntegrationType::DirectConnector,
            Some(GatewaySystem::UnifiedConnectorService),
            ShadowRolloutAvailability::IsAvailable,
        ) => Ok((
            GatewaySystem::Direct,
            ExecutionPath::ShadowUnifiedConnectorService,
        )),