fix(ucs): use NO_ERROR_CODE fallback when connector error code is absent#13095
fix(ucs): use NO_ERROR_CODE fallback when connector error code is absent#13095AmitsinghTanwar007 wants to merge 2 commits into
Conversation
When decode_connector_error_response receives a ConnectorError with no
connector_details (error_info=None), it previously fell back to the gRPC
discriminator "CONNECTOR_ERROR_RESPONSE" — causing a shadow-validation diff
on response.Err.code. Changed fallback to NO_ERROR_CODE ("No error code") to
match the HS direct path behaviour.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ab8b98e to
5d379e2
Compare
|
The change from Consider preserving the original error context even when falling back: let error_code = connector_details
.as_ref()
.map(|d| d.error_code.clone())
.unwrap_or_else(|| {
logger::warn!("Connector error code unavailable, using NO_ERROR_CODE fallback");
crate::consts::NO_ERROR_CODE.to_string()
});This ensures operational visibility into when connectors return HTTP errors without specific error codes. |
📝 Code Review: UCS Error Code FallbackThis is a straightforward fix ensuring consistent error code behavior between UCS and direct HS paths. ✅ Change AnalysisThe modification replaces a fallback that would return 💡 Minor SuggestionConsider adding a brief comment explaining why 🟢 LGTMSimple, correct fix with no blocking issues. |
|
💡 The Also verify that downstream systems (Control Center, analytics) handle these sentinel values gracefully. |
|
[nit] This PR is a clean, targeted fix. The change from |
5d379e2 to
c09924d
Compare
|
💡 Test coverage is good The unit tests added for the |
Summary
When the UCS psync path returns a connector HTTP error (4xx/5xx) with no connector-specific error code,
decode_connector_error_responsewas falling back to the gRPC discriminator string"CONNECTOR_ERROR_RESPONSE"instead of"No error code". This caused a shadow-validation diff onresponse.Err.codebetween the HS direct path and the UCS path for connectors (e.g. cybersource psync) that return error responses without a specific error code.Diff signature:
router.valueDiff:response.Err.codeLayer: HS→UCS mapping (
hyperswitch_interfaces/src/unified_connector_service/transformers.rs)Flow: cybersource / psync
Root cause
When a connector returns a 4xx error with no specific error code:
build_error_response→code = "No error code"(theNO_ERROR_CODEconstant)build_error_response→code = "No error code"→ForeignFrom<&ErrorResponse>: sincecode == NO_ERROR_CODEANDreason == None,has_connector_details = false→error_info = Nonein the gRPCConnectorErrormessage → HSdecode_connector_error_response:connector_detailsisNone→ the.unwrap_or_else(|| connector_error.error_code.clone())fallback returned"CONNECTOR_ERROR_RESPONSE"← wrongThe fix changes the fallback from
connector_error.error_code.clone()tocrate::consts::NO_ERROR_CODE.to_string()so both paths surface"No error code"when the connector provides no specific code.Verification
Verified by source-parity analysis (cybersource TLS-blocked locally):
Before fix:
decode_connector_error_responsefallback →code = "CONNECTOR_ERROR_RESPONSE"→ HS shadow diff:response.Err.code="No error code"(HS) vs"CONNECTOR_ERROR_RESPONSE"(UCS)After fix:
decode_connector_error_responsefallback →code = "No error code"→ both paths agree →no_diffUnit tests added:
decode_prefers_connector_details_code: whenconnector_details.code = Some("INVALID_REQUEST")→ surfaced code is"INVALID_REQUEST"decode_falls_back_to_no_error_code_when_connector_code_absent: whenerror_info = None→ surfaced code is"No error code"Closes #13094