fix(connectors): graceful response deserialization for loonie#12731
fix(connectors): graceful response deserialization for loonie#12731sai-harsha-vardhan wants to merge 6 commits into
Conversation
…uestType and TransactionStatus
…+ handle match arms
…ncelStatus, OutcomeCode, PaypalSourceVerificationStatus, LiabilityShift, DisputeLifeCycleStage, DisputeStatus
XyneSpaces
left a comment
There was a problem hiding this comment.
Review: Graceful Response Deserialization for Loonie + Multiple Connectors
✅ Approved
This PR applies the standard "graceful response deserialization" fixes to prevent SEV incidents. The pattern is consistent across all connectors:
- Loonie: Added
#[serde(other)] Unknownvariants to all response enums - Authorize.Net: Added
Unknownvariant to webhook events and result codes - Mollie: Converted unused response fields to
Option<Secret<T>> - PayPal: Added
Unknownvariants to incremental auth, extended auth, cancel status, and dispute outcome enums - Shift4: Added
Unknownvariant to payment/refund status; wrapped unused fields inSecret - Zift: Already has
Unknownvariant support (PR #12730 covers this separately)
💡 Findings
1. Consistent status preservation pattern
All connectors follow the same pattern: on Unknown status, log a warning and return Ok(item.data) to preserve the existing payment state. This is the correct approach.
2. Authorize.Net webhook mapping
The Unknown webhook event maps to SyncStatus::GeneralError, which eventually becomes WebhookEventTypeNotFound. This is appropriate — unknown webhook events should not be silently accepted.
3. Shift4 field conversions
The conversion of unused fields like currency, amount, first6, last4, brand to Option<Secret<T>> is correct — these fields aren't consumed in business logic and making them opaque prevents hard failures when Shift4 changes response shapes.
🔍 Minor Notes
- The PR description only mentions Loonie but the diff includes changes to 6+ connectors. The implementation is correct, but consider updating the PR title/description to reflect the full scope.
- All warning logs follow the same pattern, making it easy to search for "unknown" responses in logs.
Verdict: Clean implementation following established patterns. Ready to merge.
Summary
Applied "graceful response deserialization" fixes to the loonie connector to prevent production SEV-1/SEV-2 incidents when the connector adds new fields, enum variants, or changes response structures.
Changes Made
#[serde(other)] Unknownvariants to all response enums used in business logic:LoonioTransactionStatusRefundStatusLoonioWebhookEventCodeLoonioWebhookTransactionTypeLoonioPayoutStatusOk(item.data)(preserving existing state) when anUnknownvariant is received, instead of overwritingUnknown/Noneto the database.#[serde(deny_unknown_fields)]attributes exist on response structs.Testing
cargo check.