fix(connectors): graceful response deserialization for klarna#12726
fix(connectors): graceful response deserialization for klarna#12726sai-harsha-vardhan wants to merge 1 commit into
Conversation
Changed Files
|
XyneSpaces
left a comment
There was a problem hiding this comment.
Review: Graceful Response Deserialization for Klarna
✅ Approved
This PR applies the standard graceful deserialization fixes to the Klarna connector:
-
Fix 2 (Enum catch-alls): Added
#[serde(other)] Unknownvariants to:KlarnaFraudStatus(used in SDK authorize response)KlarnaCheckoutStatus(used in redirect authorize response)KlarnaPaymentStatus(used in PSync response)
-
Warning logs and state preservation: All
Unknownvariants log warnings and returnPendingstatus to preserve existing payment state rather than failing.
💡 Findings
1. Clean separation of concerns
Each enum has its own handler function (get_fraud_status, get_checkout_status, From<KlarnaPaymentStatus>) with consistent warning log patterns.
2. Appropriate fallback choice
Pending is the correct fallback for all Unknown variants — we don't know the actual state and shouldn't mark payments as failed/charged incorrectly.
🔍 Nit
The warning log messages vary slightly in format between the three handlers. Consider standardizing to a consistent pattern for easier log parsing:
"Unknown Klarna {fraud/checkout/payment} status received, preserving current state"
Verdict: Clean implementation following established patterns. Ready to merge.
Summary
Adds graceful response deserialization fixes for the Klarna connector:
Changes
#[serde(other)] Unknownvariant toKlarnaFraudStatusenum (used in authorize response for SDK payments)#[serde(other)] Unknownvariant toKlarnaCheckoutStatusenum (used in authorize response for redirect payments)#[serde(other)] Unknownvariant toKlarnaPaymentStatusenum (used in payment sync response)Unknownmatch arm logs a warning and returnsPendingstatus (preserves existing state rather than failing)Notes
#[serde(deny_unknown_fields)]attributes existed on any Klarna response structs — no Fix 1 changes neededhyperswitch_interfacesunrelated to Klarna