You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_0 (already cloned)
- Base commit: a589e2246447b7096fd335d444a24b2450c3e7c2
- Task ID: juspay__hyperswitch-9027
- Version: v1.116.0
TASK DESCRIPTION: Bug: [BUG] There is a bug when the webhook response comes from ucs
Bug Description
There is a bug when the webhook response comes from ucs, the code was not able to deserialize the response
Expected Behavior
webhook response form ucs should be handle using ucs logic
Actual Behavior
a webhook failed
Steps To Reproduce
Provide an unambiguous set of steps to reproduce this bug. Include code or configuration to reproduce, if relevant.
- Go to '...'
- Click on '....'
- Scroll down to '....'
Context For The Bug
No response
Environment
Are you using hyperswitch hosted version? Yes/No If yes, please provide the value of the
x-request-idresponse header to help us debug your issue.If not (or if building/running locally), please provide the following details:
- Operating System or Linux distribution:
- Rust version (output of
rustc --version): `` - App version (output of
cargo r --features vergen -- --version): ``
Have you spent some time checking if this bug has been raised before?
- I checked and didn't find a similar issue
Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit a PR?
None
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
Assistant
I'll help you fix this bug related to webhook responses from UCS. Let me start by understanding the issue and exploring the codebase to locate the relevant files.
First, let me create a plan for tackling this issue:
Assistant
Let me first explore the repository structure to understand how webhooks are handled, particularly looking for UCS-related code.
Assistant
Now let me look specifically at the incoming webhook handler to understand how it processes UCS webhooks:
Assistant
Let me search for specific parts of the webhook handling code related to UCS:
Assistant
Let me look at the unified connector service file to understand how UCS handles webhook responses:
Assistant
Now let me examine the transformers module to understand how UCS webhook responses are handled:
Assistant
Let me look at the incoming webhook processing code to understand how it handles UCS responses:
Assistant
Let me continue reading the rest of the incoming webhook processing to understand how it handles the UCS flow:
Assistant
Let me check for any existing Psync flow implementations that handle webhook consumption specifically:
Assistant
(no content)
Assistant
Now I have a good understanding of the problem. Looking at the code, I can see that:
- The code uses a UCS (Unified Connector Service) for webhook processing when
should_call_unified_connector_service_for_webhooks()returns true - In
process_ucs_webhook_transform(), the code callsunified_connector_service::call_unified_connector_service_for_webhook()which returns aWebhookTransformData - The issue is that when handling webhook responses from UCS, the code is likely not correctly handling deserialization of UCS responses in some cases
Looking closely at the psync_flow.rs, I can see that when
CallConnectorAction::HandleResponseis used, the code inexecute_connector_processing_step_for_each_captureonly calls the connector once, but there might be issues when the response comes from UCS specifically.Let me continue my investigation to understand the bug more precisely. Let me also check what changed in the referenced PR:
- The code uses a UCS (Unified Connector Service) for webhook processing when
Assistant
Let me approach this differently. Based on the issue description, I need to understand what the bug is exactly. The problem statement says:
- There is a bug when the webhook response comes from UCS
- The code was not able to deserialize the response
- Expected behavior: webhook response from UCS should be handled using UCS logic
- Actual behavior: a webhook failed
Let me look for more clues about the issue by checking recent commits and the specific bug mentioned in the PR:
Assistant
Let me search for more specific error patterns or issues related to UCS webhooks in the codebase:
Assistant
Let me also check for any recent changes related to webhooks and UCS by checking git history:
Assistant
Based on my analysis, I can see that the bug is likely related to the deserialization process when handling webhook responses that come from UCS. Looking at the code in
psync_flow.rs, I see that in theexecute_connector_processing_step_for_each_capturemethod, whenCallConnectorAction::HandleResponseis used (which is the case for webhook consumption), it only executes connector processing once.However, the issue might be that when webhook responses are coming from UCS, they need special handling that's not properly implemented. Let me check what the actual issue is by reading more of the code around the problematic areas.
Looking at the
process_webhook_business_logicfunction inincoming.rs, I can see that the function gets awebhook_transform_dataparameter and handles it appropriately by checking if it's a UCS response () or falls back to traditional connector extraction.Assistant
Looking more carefully at the code, I realize I need to actually make a code change. Based on my analysis of the problem:
- The issue occurs when webhook responses come from UCS (Unified Connector Service)
- The current payment sync flow (
PSync) usesCallConnectorAction::HandleResponsefor webhook consumption - When UCS is used for webhook processing, it should properly deserialize the UCS response
Looking at the payment sync flow code again, I can see in
psync_flow.rsat line 309-321, whenCallConnectorAction::HandleResponseis detected, it only makes one connector call (for webhooks). However, the issue likely stems from how the data gets passed from the UCS processing back to the payment flow.Let me check if there's an existing problem in the way the webhook data flows through the system by implementing a focused fix:
Assistant
I don't have permission to write files. Let me reconsider the approach and understand what the exact issue is.
Let me look closer at the issue and the PR reference. From the task description, the PR says:
while handling the response of UCS for webhooks Hyperswitch used to use the existing connector code (Psync's Handle Respnse) which gave error for UCS response so fixed this issue.
The problem likely isn't in the psync flow itself, but rather that when a webhook comes from UCS, it's going through the wrong flow path or the wrong deserialization logic.
Let me carefully trace through what I think the real problem is. Looking at how the system works:
- Incoming webhook comes in →
incoming_webhooks_core - If UCS is enabled, it calls
process_ucs_webhook_transform - That calls
unified_connector_service::call_unified_connector_service_for_webhook - This gives us a
WebhookTransformDatawith awebhook_contentfield - Later, in
process_webhook_business_logic, it passes that to the payment flow
But looking more closely at how this flows through to payments sync, the problem might be more subtle.
- Incoming webhook comes in →
Assistant
Let me carefully reconsider the issue. The task is to understand and fix a bug where "webhook response form ucs should be handle using ucs logic".
Based on what I've seen in the code, the problem is not necessarily in the psync flow but in how UCS responses are handled when they reach the payment sync flow in the context of webhooks.
Looking more carefully at the logic, when a webhook is processed through UCS:
- The incoming webhook is handled via
incoming_webhooks_core - It detects UCS should be used for webhook processing
- It calls
process_ucs_webhook_transformwhich gets aWebhookTransformData - Then it calls
process_webhook_business_logic - This eventually calls
payments_incoming_webhook_flow - Which calls
payments_corewithCallConnectorAction::HandleResponse
The problem may be in the deserialization of the response from UCS in that path.
However, instead of guessing at a fix, let me re-read the issue more carefully. I should approach this methodically and look for the actual difference in handling between UCS and traditional webhook paths.
Let me create a clearer analysis of what the real issue is:
- The incoming webhook is handled via
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.