-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(core): Implement UCS kill switch for emergency fallback #8651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changed Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a database-driven kill switch for the Unified Connector Service (UCS) to allow operators to disable UCS without deployments.
- Adds
UCS_KILL_SWITCH_ACTIVE
constant for the kill switch key - Implements
is_kill_switch_active
helper and integrates early kill-switch check inshould_call_unified_connector_service
- Updates internal payment flow to return an explicit error when UCS is disabled
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
crates/router/src/consts.rs | Added UCS_KILL_SWITCH_ACTIVE constant for kill-switch configuration |
crates/router/src/core/payments/helpers.rs | Implemented is_kill_switch_active helper to fetch and parse kill-switch status |
crates/router/src/core/unified_connector_service.rs | Integrated kill-switch check and removed redundant client existence check at the end of rollout logic |
crates/router/src/core/payments.rs | Changed internal payments path to return error when UCS kill-switch is active, removing fallback |
Comments suppressed due to low confidence (2)
crates/router/src/core/payments/helpers.rs:2040
- [nitpick] Consider adding a doc comment above
is_kill_switch_active
to explain its purpose, default behavior on errors, and how it fits into the UCS decision flow.
pub async fn is_kill_switch_active(state: &SessionState, config_key: &str) -> RouterResult<bool> {
crates/router/src/core/payments/helpers.rs:2040
- There are no unit tests for
is_kill_switch_active
covering success, parse failures, and DB errors. Adding tests would help ensure correct behavior and prevent regressions.
pub async fn is_kill_switch_active(state: &SessionState, config_key: &str) -> RouterResult<bool> {
logger::error!(error = ?err, "Failed to parse {config_key:?} kill switch config"); | ||
Ok(false) | ||
} | ||
}, | ||
Err(err) => { | ||
logger::error!(error = ?err, "Failed to fetch {config_key:?} kill switch config from DB"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message uses a literal {config_key:?}
placeholder instead of interpolating the variable. Consider using something like "Failed to parse kill switch config for key {}"
and passing config_key
as an argument for clarity.
logger::error!(error = ?err, "Failed to parse {config_key:?} kill switch config"); | |
Ok(false) | |
} | |
}, | |
Err(err) => { | |
logger::error!(error = ?err, "Failed to fetch {config_key:?} kill switch config from DB"); | |
logger::error!(error = ?err, config_key = config_key, "Failed to parse kill switch config for key {}", config_key); | |
Ok(false) | |
} | |
}, | |
Err(err) => { | |
logger::error!(error = ?err, config_key = config_key, "Failed to fetch kill switch config for key {} from DB", config_key); |
Copilot uses AI. Check for mistakes.
logger::error!(error = ?err, "Failed to parse {config_key:?} kill switch config"); | ||
Ok(false) | ||
} | ||
}, | ||
Err(err) => { | ||
logger::error!(error = ?err, "Failed to fetch {config_key:?} kill switch config from DB"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log also uses {config_key:?}
literally. Change to a formatted message, e.g., "Failed to fetch kill switch config for key {} from DB"
, passing config_key
as an argument.
logger::error!(error = ?err, "Failed to parse {config_key:?} kill switch config"); | |
Ok(false) | |
} | |
}, | |
Err(err) => { | |
logger::error!(error = ?err, "Failed to fetch {config_key:?} kill switch config from DB"); | |
logger::error!(error = ?err, "Failed to parse kill switch config for key {}", config_key); | |
Ok(false) | |
} | |
}, | |
Err(err) => { | |
logger::error!(error = ?err, "Failed to fetch kill switch config for key {} from DB", config_key); |
Copilot uses AI. Check for mistakes.
crates/router/src/core/payments.rs
Outdated
return Err( | ||
errors::ApiErrorResponse::InternalServerError | ||
) | ||
.attach_printable("Unified connector service is down and traditional connector service fallback is not implemented"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chaining attach_printable
directly on return Err(...)
may not wrap the error as intended. Consider applying attach_printable
before converting or returning the error, for example:
let err = ApiErrorResponse::InternalServerError.attach_printable("...");
return Err(err);
Copilot uses AI. Check for mistakes.
…ordea-sepa * 'main' of github.com:juspay/hyperswitch: refactor(connector): [Adyen] map ssn and session validity for Pix (#8702) feat(core): Implement UCS kill switch for emergency fallback (#8651) fix(openapi): Added Error Response Schema for Status Code 400 (#8684) feat(connector): Add template code for breadpay (#8655) chore(version): 2025.07.21.1 refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681) fix(router): Make v2 endpoints follow standard naming conventions (#8630) fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards (#8663) feat(routing): Add API key auth for decision engine endpoints (#8640) feat(authentication): Added eligibility flow for modular authentication (#8431) feat(connector): [BLACKHAWKNETWORK] Add Template Code (#8632) fix: remove straight through routing from routing approach (#8695) fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689) chore(version): 2025.07.21.0
…ayload-recurring * 'main' of github.com:juspay/hyperswitch: (48 commits) fix(connector): Add Trustpay in Authentication Providers Config (#8622) refactor(connector): [Adyen] map ssn and session validity for Pix (#8702) feat(core): Implement UCS kill switch for emergency fallback (#8651) fix(openapi): Added Error Response Schema for Status Code 400 (#8684) feat(connector): Add template code for breadpay (#8655) chore(version): 2025.07.21.1 refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681) fix(router): Make v2 endpoints follow standard naming conventions (#8630) fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards (#8663) feat(routing): Add API key auth for decision engine endpoints (#8640) feat(authentication): Added eligibility flow for modular authentication (#8431) feat(connector): [BLACKHAWKNETWORK] Add Template Code (#8632) fix: remove straight through routing from routing approach (#8695) fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689) chore(version): 2025.07.21.0 feat(debit_routing): add debit routing support for apple pay (#8673) refactor(router): decrypt the wallet token before the debit routing call (#8598) chore: update org retrieve api response to include org type (#8660) feat(routing): Add routing evaluation rule endpoint and related flow (#8656) fix(connector): [AUTHORIZEDOTNET] Added Invoice Number Fix (#8685) ...
…acilitapay-mca-metadata * 'main' of github.com:juspay/hyperswitch: fix(connector): Add Trustpay in Authentication Providers Config (#8622) refactor(connector): [Adyen] map ssn and session validity for Pix (#8702) feat(core): Implement UCS kill switch for emergency fallback (#8651) fix(openapi): Added Error Response Schema for Status Code 400 (#8684) feat(connector): Add template code for breadpay (#8655) chore(version): 2025.07.21.1 refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681) fix(router): Make v2 endpoints follow standard naming conventions (#8630) fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards (#8663) feat(routing): Add API key auth for decision engine endpoints (#8640) feat(authentication): Added eligibility flow for modular authentication (#8431) feat(connector): [BLACKHAWKNETWORK] Add Template Code (#8632) fix: remove straight through routing from routing approach (#8695) fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689)
feat(core): Implement UCS enable/disable configuration for operational control
Type of Change
Fixes #8644
Description
This PR implements a database-driven enable/disable configuration for the Unified Connector Service (UCS) integration, providing operators with immediate control to enable or disable UCS without requiring code changes or deployments.
Key Features Implemented:
UCS_ENABLED
configArchitecture:
Key Technical Improvements:
is_ucs_enabled()
function queries database configFiles Modified:
crates/router/src/consts.rs
- AddedUCS_ENABLED
constantcrates/router/src/core/payments/helpers.rs
- Addedis_ucs_enabled()
helper functioncrates/router/src/core/unified_connector_service.rs
- Integrated UCS enabled check in decision flowcrates/router/src/core/payments.rs
- Updated fallback behavior for internal operationsImportant Caveat:
payments_operation_core
): When UCS is disabled,should_call_unified_connector_service()
returns false and traditional connector flow is usedinternal_payments_operation_core
): Fallback to traditional connector flow has been removed - system now returns error when UCS is unavailableAdditional Changes
Motivation and Context
Operational Safety Requirements:
This change addresses critical operational needs for managing the UCS integration in production environments:
Incident Response:
Risk Management:
Implementation Benefits:
Use Cases:
How did you test it?
Manual Testing
Test Scenario: UCS Enable/Disable Toggle Behavior
1. Default Behavior (UCS Not Configured/Disabled)
2. Enable UCS
3. Test with UCS Enabled
Sample Payment Request:
4. Disable UCS
5. Verify UCS is Disabled
Additional Test Cases:
Test Invalid Config Value:
Retrieve Current UCS Status:
Expected Results:
false
),should_call_unified_connector_service()
returns falsetrue
), normal UCS rollout logic appliesChecklist
cargo +nightly fmt --all
cargo clippy