Skip to content

fix(connectors): graceful response deserialization for zift#12730

Open
sai-harsha-vardhan wants to merge 1 commit into
mainfrom
fix-zift-response-deserialization
Open

fix(connectors): graceful response deserialization for zift#12730
sai-harsha-vardhan wants to merge 1 commit into
mainfrom
fix-zift-response-deserialization

Conversation

@sai-harsha-vardhan

Copy link
Copy Markdown
Contributor

Summary

Apply the three standard graceful response deserialization fixes to the Zift connector.

Fix 1 — Remove #[serde(deny_unknown_fields)] from response structs

No #[serde(deny_unknown_fields)] attributes existed on response structs in the Zift connector; nothing to remove.

Fix 2 — Add #[serde(other)] Unknown catch-all to response enums

Added Unknown variant to enums used in business logic:

  • TransactionStatus — matched in PSync TryFrom. On Unknown, logs a warning and returns Ok(item.data) (preserves existing payment status).
  • PaymentRequestType — matched in PSync TryFrom. On Unknown, logs a warning and returns Ok(item.data) (preserves existing payment status).

Nested match arms use TransactionStatus::Unknown => unreachable!() because the outer check handles Unknown early.

Fix 3 — Unused fields → opaque optional types

  • ZiftErrorResponse.failure_code: StringOption<Secret<String>>
  • ZiftErrorResponse.failure_message: StringOption<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_utils issues unrelated to this change.

Resolves HYP-43.

@sai-harsha-vardhan sai-harsha-vardhan requested a review from a team as a code owner June 11, 2026 16:03
@semanticdiff-com

semanticdiff-com Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/zift/transformers.rs  4% smaller

@XyneSpaces XyneSpaces left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Graceful Response Deserialization for Zift

✅ Approved

This PR applies the standard graceful deserialization fixes to the Zift connector:

  1. Fix 2 (Enum catch-alls): Added #[serde(other)] Unknown to TransactionStatus and PaymentRequestType
  2. Fix 3 (Opaque optional types): Changed ZiftErrorResponse.failure_code and failure_message from String to Option<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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants