fix(connectors): graceful response deserialization for finix#12725
fix(connectors): graceful response deserialization for finix#12725sai-harsha-vardhan wants to merge 4 commits into
Conversation
XyneSpaces
left a comment
There was a problem hiding this comment.
Review: Finix Graceful Response Deserialization
💡 Suggestion: Consider clarifying comment for Unknown mapping
The FinixDisputeState::Unknown variant maps to EventNotSupported, which is appropriate. However, consider adding a brief inline comment explaining why this doesn't return an error, unlike typical webhook parsing failures.
FinixDisputeState::Unknown => {
// Unknown dispute states are explicitly non-fatal to prevent
// breaking webhook processing when Finix adds new states
router_env::logger::warn!("Received unknown Finix dispute state in webhook");
Ok(IncomingWebhookEvent::EventNotSupported)
}🔍 Nit: Redundant FinixTags type alias
The FinixTags type alias appears to be removed from usage but the import may remain. Verify that use std::collections::HashMap; and any FinixTags type definition can also be removed if no longer used.
Verdict: Implementation follows the graceful deserialization pattern correctly. Minor documentation suggestions only.
| @@ -821,6 +821,12 @@ impl FinixWebhookBody { | |||
| FinixDisputeState::INQUIRY => Ok(IncomingWebhookEvent::DisputeChallenged), | |||
There was a problem hiding this comment.
💡 Consider adding a brief comment explaining why Unknown maps to EventNotSupported rather than an error, for future maintainers.
| pub failure_message: Option<String>, | ||
| pub transfer: Option<String>, | ||
| pub tags: FinixTags, | ||
| pub tags: Option<Secret<serde_json::Value>>, |
There was a problem hiding this comment.
🔍 Verify that the FinixTags type definition and HashMap import can be removed if no longer referenced elsewhere.
XyneSpaces
left a comment
There was a problem hiding this comment.
Review Summary
Verdict: ✅ Approve
Classification: Connector - graceful response deserialization fixes
Risk: Low
This PR applies standard graceful response deserialization patterns across multiple connectors (Finix, BankOfAmerica, Checkout, Cybersource, WorldpayModular). Changes follow the established connector patterns for handling unknown enum variants and securing unused response fields.
Findings
💡 1. Consistent pattern application for graceful deserialization
All modified connectors now have #[serde(other)] Unknown variants on response enums and wrap unused fields in Secret<serde_json::Value>>. This prevents production incidents when connectors add new fields or enum variants.
Files Reviewed
crates/hyperswitch_connectors/src/connectors/finix/transformers/response.rscrates/hyperswitch_connectors/src/connectors/finix/transformers.rscrates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rscrates/hyperswitch_connectors/src/connectors/checkout/transformers.rscrates/hyperswitch_connectors/src/connectors/cybersource.rscrates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers.rscrates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers/response.rs
Pre-existing Issues (not introduced by this PR)
- None identified
Summary
This PR applies the three standard graceful response deserialization fixes to the Finix connector:
Fix 1 — Removed deny_unknown_fields
#[serde(deny_unknown_fields)]existed on any response structs in this connectorFix 2 — Added catch-all variant to response enums used in business logic
#[serde(other)] Unknownvariant toFinixDisputeStateEventNotSupportedand log a warning for unknown dispute statesFix 3 — Made unused response fields opaque optional types
tags(HashMap/FinixTags) →Option<Secret<serde_json::Value>>inFinixPaymentsResponse,FinixIdentityResponse,FinixInstrumentResponseentity(HashMap) →Option<Secret<serde_json::Value>>inFinixIdentityResponsethree_d_secure(nested struct) →Option<Secret<serde_json::Value>>inFinixPaymentsResponseinstrument_type(enum) →Option<Secret<String>>inFinixInstrumentResponsecard_type(enum) →Option<Secret<String>>inFinixInstrumentResponseaddress(nested struct) →Option<Secret<serde_json::Value>>inFinixInstrumentResponsecreated_at,updated_at,application,created_via,identity→ made optional and/or wrapped inSecret<String>as neededFiles Changed
crates/hyperswitch_connectors/src/connectors/finix/transformers/response.rscrates/hyperswitch_connectors/src/connectors/finix/transformers.rs