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: 00e056800cb2c75c4dfbed6a4451658fda9c4a86
- Task ID: juspay__hyperswitch-7620
- Version: v1.113.0
TASK DESCRIPTION: Bug: feat(cypress):
connectorUpdateCallfails due to fixtures overwriteThe
connectorUpdateCallfails in the Cypress Tests for connectors for which a certain metadata field isrequired(for e.g.,Braintree) because thecypress-tests/cypress/fixtures/update-connector-body.jsonoverwrites the Request Body.DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
The Connector Update Body is being overwritten, which included the metadata as well. Due to this, if there were any required metadata fields of a connector, then the Connector Update Test would fail.
For example,
Braintreeconnector has a required metadata field, and while testing the Connector Update, just because it was being overwritten by theupdate-connector-body.jsonfixture, the test fails as shown in the following screenshot.Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
While adding the Card test Flows for the
Braintreeconnector, the Connector Update Test Failed.How did you test it?
Running the
0000-CoreFlows.cy.jsfor connector Assistant
I'll analyze the bug with
connectorUpdateCallfailing due to fixtures overwrite in the Cypress tests. Let me first understand the issue by examining the relevant files.Assistant
Let me first examine the fixture file that's causing the issue:
Assistant
Now let me find the connectorUpdateCall implementation in the Cypress tests:
Assistant
Let me search more broadly for connector-related Cypress tests:
Assistant
(no content)
Assistant
Let me check what's in the cypress-tests directory:
Assistant
(no content)
Assistant
Let me search for connector update related tests:
Assistant
Let me look at the support commands where connectorUpdateCall is likely defined:
Assistant
(no content)
Assistant
Let me search for a broader pattern to understand how the connector update tests work:
Assistant
(no content)
Assistant
Let me look at the specific CoreFlows test file that was mentioned in the issue:
Assistant
(no content)
Assistant
Let me find the correct path to the CoreFlows file:
Assistant
(no content)
Assistant
Now I found the issue! On line 147-153, we can see the connectorUpdateCall test is using the fixtures.updateConnectorBody. Let me check what's in the imports.js file to see the fixtures:
Assistant
Now let me examine the commands.js file to see how connectorUpdateCall is implemented:
Assistant
Let me look at the commands.js file differently by reading specific sections:
Assistant
(no content)
Assistant
Perfect! Now I can see the issue clearly. In the connectorUpdateCall function (lines 815-849), it's using the
updateConnectorBodydirectly from the fixture (line 836) without merging it properly with existing connector data. This causes the metadata to be completely replaced rather than merged, which breaks connectors that require certain metadata fields.Let me now examine the Braintree connector to understand what metadata is required:
Assistant
Let me check the required fields configuration for connectors:
Assistant
Let me search for Braintree specific configurations:
Assistant
Let me check the Braintree connector file itself to understand the required metadata:
Assistant
Now let me check the Braintree transformers to see if I can find metadata requirements:
Assistant
Let me examine the create-connector-body.json to see the original connector creation data:
Assistant
(no content)
Assistant
Now let me update the todo list with my findings and create a plan for fixing the issue:
Assistant
Based on my analysis, I now understand the bug clearly. Let me fix it:
-
Problem Analysis:
- In
connectorUpdateCallin/workspace/archit/trace_generation/repos/hyperswitch_pool_0/cypress-tests/cypress/support/commands.js, the test is directly passing theupdateConnectorBodyfixture (which contains metadata) to the API request without merging it with existing connector data. - When a connector like Braintree requires specific metadata fields, and these are missing from the fixture, the entire metadata gets overwritten, causing validation failures.
- In
-
Root Cause:
- Line 836 in
commands.jsusesbody: updateConnectorBodydirectly, which overwrites existing metadata rather than merging it.
- Line 836 in
-
Solution:
- We need to merge the update fixture data with existing connector data to preserve required metadata fields from the original connector.
Let me implement the fix:
-
Assistant
I need to read the file first to understand its structure before making changes:
Assistant
I'll implement the fix for the connector update bug by modifying the connectorUpdateCall function to properly merge metadata instead of overwriting it.
First, let me check how connector metadata is stored in the global state to make sure I understand the data structure correctly:
Assistant
Let me look for how connector metadata is retrieved or accessed in tests:
Assistant
Let me get a broader view of how connector metadata is used in the codebase:
Assistant
Let me just make the edit directly. I'll make a simpler approach that handles the metadata merge more carefully:
Assistant
I'll create a patch file instead to document the changes I would make:
Assistant
I understand that I cannot write files due to permission constraints. Let me summarize my findings and the solution for the bug:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.