Skip to content

refactor(routing): add conditional check for invoking DE routing flows #8559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2025

Conversation

Sarthak1799
Copy link
Contributor

@Sarthak1799 Sarthak1799 commented Jul 6, 2025

Type of Change

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

Description

This PR introduces a conditional check for Decision Engine (DE) Euclid API integration within the static routing flow. Previously, the system always attempted to perform Euclid-based routing regardless of configuration. With this change, the Euclid routing flow is invoked only if the OpenRouter URL is configured.

Additionally, some unused or redundant code around logging and comments has been cleaned up in utils.rs.

Outcomes

  • Prevents unnecessary calls to the Euclid API when the OpenRouter URL is not configured, reducing overhead and potential timeouts.
  • Ensures cleaner and more consistent logs by removing redundant debug statements and placeholders.
  • Improves maintainability by scoping the Euclid integration behind a clear configuration flag.

Diff Hunk Explanation

crates/router/src/core/payments/routing.rs

  • Wrapped the perform_decision_euclid_routing call with a check for state.conf.open_router.url.
  • Added a fallback to return an empty connector list if OpenRouter is not configured.

crates/router/src/core/payments/routing/utils.rs

  • Removed a redundant placeholder comment about logging Euclid response events.
  • Streamlined debug logs for Euclid responses.

This PR addresses an integration improvement for Euclid static routing checks in the decision engine.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Can be tested directly in prod as that is the only environment where this env in missing.

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Sarthak1799 Sarthak1799 self-assigned this Jul 6, 2025
@Sarthak1799 Sarthak1799 requested a review from a team as a code owner July 6, 2025 15:12
@Sarthak1799 Sarthak1799 added the A-routing Area: Routing label Jul 6, 2025
Copy link

semanticdiff-com bot commented Jul 6, 2025

@Sarthak1799 Sarthak1799 changed the title fix: Added DE check for euclid API fix(routing): Added DE check for euclid API Jul 6, 2025
prajjwalkumar17
prajjwalkumar17 previously approved these changes Jul 6, 2025
@prajjwalkumar17 prajjwalkumar17 linked an issue Jul 7, 2025 that may be closed by this pull request
@prajjwalkumar17 prajjwalkumar17 changed the title fix(routing): Added DE check for euclid API refactor(routing): add conditional check for invoking DE routing flows Jul 7, 2025
prajjwalkumar17
prajjwalkumar17 previously approved these changes Jul 7, 2025
Chethan-rao
Chethan-rao previously approved these changes Jul 7, 2025
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

And please add validation to confirm that open router URL is not empty when open router is enabled.

true,
false,
);
let de_euclid_connectors = if !state.conf.open_router.url.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use open_router.enabled instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want euclid for diff check even when DE is disabled. So if the env is present (the url i.e.) we'll make the call for euclid but not other algorithms as they have a open_router.enabled check.

Copy link
Member

Choose a reason for hiding this comment

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

Why such a distinction?

In my opinion, this makes it harder when debugging, since someone self-hosting may have set open router enabled to false with a placeholder URL (say referring to our sample config), expecting it to not call open router, but it would still try to?

[open_router]
enabled = true # Enable or disable Open Router
url = "http://localhost:8080" # Open Router URL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diff check is a short term process. We'll remove this check entirely in some time and rely completely on the open_router.enabled @SanchithHegde

@Sarthak1799 Sarthak1799 dismissed stale reviews from Chethan-rao and prajjwalkumar17 via 767a351 July 7, 2025 18:27
@Sarthak1799 Sarthak1799 requested a review from a team as a code owner July 7, 2025 18:27
@Sarthak1799 Sarthak1799 requested a review from a team as a code owner July 8, 2025 09:54
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 8, 2025
Merged via the queue into main with commit 7508c80 Jul 8, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the euclid-events-fix branch July 8, 2025 13:35
pixincreate added a commit that referenced this pull request Jul 9, 2025
…ayload-webhooks

* 'main' of github.com:juspay/hyperswitch:
  refactor(connector): Move connector mappings and endpoints to dedicated modules (#8562)
  ci(cypress): fix `hipay` test cases (#8563)
  chore(version): 2025.07.09.0
  fix(payment_method): update entity id used for Vault to global customer id (#8380)
  refactor(routing): add conditional check for invoking DE routing flows (#8559)
  feat(connector): [AUTHIPAY] Integrate cards non 3ds payments (#8266)
  ci(cypress): add payu connector (#8567)
  feat(connector): [silverflow] template code (#8553)
  chore(version): 2025.07.08.0
  feat(cypress): [worldpayvantiv] add cypress test (#8234)
  feat(connectors): [worldpayvantiv] add connector mandate support  (#8546)
  feat(connector): [Celero] add Connector Template Code (#8489)
  feat(payment-methods): create payment_token in vault confirm / do payment-confirm with temp token from session (#8525)
  ci(cypress): Add Tsys,Square cypress test (#8543)
  chore(version): 2025.07.07.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: Conditoinal config for invoking DE routing
5 participants