Skip to content

Conversation

AnkitKmrGupta
Copy link
Contributor

@AnkitKmrGupta AnkitKmrGupta commented Oct 13, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Tagged Issue
https://github.com/juspay/hyperswitch-cloud/issues/11471

Description

This pull request refactors how the business profile is retrieved in the update_default_routing_config_for_profile function, simplifying the code and improving clarity. The main change is replacing the previous utility function with a direct call to the database method for fetching the business profile.

Business profile retrieval refactor:

  • Replaced the use of core_utils::validate_and_get_business_profile with a direct call to db.find_business_profile_by_merchant_id_profile_id, removing unnecessary intermediate steps and improving code readability.

How did you test it?

Using invalid profile_id

curl --location 'http://localhost:8080/routing/default/profile/pro_DSlIrgnRLgZzRftRudao' \
--header 'api-key: dev_qLOy4NXEpgJyGQQL7Jr3scus3rN4vlZttGssX3KjkEaN7AGWzi5yWjTlfqhVGu8d' \
--header 'content-type: application/json' \
--data '[
    {
        "connector": "stripe",
        "merchant_connector_id": "mca_BuSL5KElo4H7qEFgB0uY"
    }
]'
{
    "error": {
        "type": "invalid_request",
        "message": "Business profile with the given id pro_DSlIrgnRLgZzRftRudao does not exist",
        "code": "HE_02"
    }
}

using valid profile_id

curl --location 'http://localhost:8080/routing/default/profile/pro_Ukun8dROJO9OFBXoKLeL' \
--header 'api-key: dev_qLOy4NXEpgJyGQQL7Jr3scus3rN4vlZttGssX3KjkEaN7AGWzi5yWjTlfqhVGu8d' \
--header 'content-type: application/json' \
--data '[
    {
        "connector": "stripe",
        "merchant_connector_id": "mca_qPmOP94g3ob6uSusaH1x"
    }
]'
{
    "profile_id": "pro_Ukun8dROJO9OFBXoKLeL",
    "connectors": [
        {
            "connector": "stripe",
            "merchant_connector_id": "mca_qPmOP94g3ob6uSusaH1x"
        }
    ]
}

@AnkitKmrGupta AnkitKmrGupta requested a review from a team as a code owner October 13, 2025 07:27
Copy link

semanticdiff-com bot commented Oct 13, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/routing.rs  76% smaller

@AnkitKmrGupta AnkitKmrGupta changed the title handle DecryptionError for validation fix: handle DecryptionError for validation Oct 13, 2025
jagan-jaya
jagan-jaya previously approved these changes Oct 13, 2025
@AnkitKmrGupta AnkitKmrGupta self-assigned this Oct 13, 2025
@AnkitKmrGupta AnkitKmrGupta changed the title fix: handle DecryptionError for validation fix(routing): handle validation for routing Oct 13, 2025
@AnkitKmrGupta AnkitKmrGupta changed the title fix(routing): handle validation for routing fix(routing): handle validation for profile_id Oct 13, 2025
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.

3 participants