fix(connectors): graceful response deserialization for zift#12730
fix(connectors): graceful response deserialization for zift#12730sai-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 Zift
✅ Approved
This PR applies the standard graceful deserialization fixes to the Zift connector:
- Fix 2 (Enum catch-alls): Added
#[serde(other)] UnknowntoTransactionStatusandPaymentRequestType - Fix 3 (Opaque optional types): Changed
ZiftErrorResponse.failure_codeandfailure_messagefromStringtoOption<Secret<String>>
💡 Findings
1. Early-exit pattern for Unknown status
The implementation correctly checks transaction_status == TransactionStatus::Unknown at the start of the TryFrom and returns early with Ok(item.data). This preserves the existing payment status rather than risking incorrect state transitions.
2. unreachable!() for nested matches
The inner TransactionStatus::Unknown => unreachable!() arms are correct — the early check at the function entry handles Unknown, so these arms will never be reached.
3. Error field secrecy
Converting failure_code and failure_message to Option<Secret<String>> prevents potential PII or internal error details from appearing in logs if Zift adds unexpected error field formats.
🔍 Nit
The PR description mentions the change resolves HYP-43. Consider adding a brief note about what HYP-43 addresses for future reference.
Verdict: Clean implementation following established patterns. Ready to merge.
Summary
Apply the three standard graceful response deserialization fixes to the Zift connector.
Fix 1 — Remove
#[serde(deny_unknown_fields)]from response structsNo
#[serde(deny_unknown_fields)]attributes existed on response structs in the Zift connector; nothing to remove.Fix 2 — Add
#[serde(other)] Unknowncatch-all to response enumsAdded
Unknownvariant to enums used in business logic:TransactionStatus— matched in PSyncTryFrom. OnUnknown, logs a warning and returnsOk(item.data)(preserves existing payment status).PaymentRequestType— matched in PSyncTryFrom. OnUnknown, logs a warning and returnsOk(item.data)(preserves existing payment status).Nested match arms use
TransactionStatus::Unknown => unreachable!()because the outer check handlesUnknownearly.Fix 3 — Unused fields → opaque optional types
ZiftErrorResponse.failure_code:String→Option<Secret<String>>ZiftErrorResponse.failure_message:String→Option<Secret<String>>These fields are not consumed in
build_error_response; making them opaque optional prevents hard failures when Zift adds new error field shapes.Testing
No Zift-specific compiler errors. Full workspace clippy is blocked by pre-existing
diesel_models/common_utilsissues unrelated to this change.Resolves HYP-43.