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_2 (already cloned)
- Base commit: c58e93bfdba4cbd70d69e6d3947e0e1c68504e7e
- Task ID: juspay__hyperswitch-7809
- Version: v1.113.0
TASK DESCRIPTION: Bug: Deep health check failing because of OpenSearch
When you don't have OpenSearch deployed for Global Search feature on dashboard , the
/health/ready( deep health check ) API which checks health of all the underlying queryable resources fails because if OpenSearch is not present the health check fails which should not be the case.DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
Making
OpenSearchClientoptional based on the config for querying OpenSearch Server for dashboard based on the Deployment status of the same ( OpenSearch Server ).Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
When you don't have OpenSearch deployed for Global Search feature on dashboard , the
/health/ready( deep health check ) API which checks health of all the underlying queryable resources fails because OpenSearch is not present.To make it optional based on the deployment type needs changes and should be dependent on a config which should be given out on time of router deployment
Currently if you don't have OpenSearch Deployment and have router running
curl http://localhost:8080/health/ready -v * Host localhost:8080 was resolved. * IPv6: ::1 * IPv4: 127.0.0.1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying [::1]:8080... * Connected to localhost (::1) port 8080 > GET /health/ready HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/8.7.1 > Accept: */* > * Request completely sent off < HTTP/1.1 500 Internal Server Error < content-length: 136 < access-control-expose-headers: x-request-id, content-type, via, strict-transport-security < via: HyperSwitch < x-request-id: 019634f7-a837-7d50-9a50-bb8e7651bd62 < content-type: application/json < vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers < strict-transport-security: max-age=31536000 < date: Mon, 14 Apr 2025 15:42:47 GMT < { [136 bytes data] 100 136 100 136 0 0 7613 0 --:--:-- --:--:-- --:--:-- 8000 * Connection #0 to host localhost left intact { "error": { "type": "api", "message": "Opensearch health check failed with error: Error while executing query in Opensearch", "code": "HE_00" } } Assistant
I'll tackle this bug where the deep health check fails when OpenSearch is not deployed. Let me first understand the current implementation and locate the relevant files.
Assistant
Let me first search for the health check implementation to understand how it currently works:
Assistant
Let me check the current directory structure first:
Assistant
Now let me search for health check implementations in the crates directory:
Assistant
Let me search more broadly for health-related code:
Assistant
Let me just search in the current directory:
Assistant
(no content)
Assistant
Let me search for health routes more specifically:
Assistant
Let me check the routes directory structure to understand where the health endpoints are defined:
Assistant
Perfect! Now let me examine the health route files:
Assistant
Now I can see the issue! At line 113-120, the OpenSearch health check is guarded by
#[cfg(feature = "olap")], which means it only runs when that feature is enabled. However, the error message shows that it's still failing when OpenSearch is not present, indicating that it's running even when the feature is disabled. Let me also check the v2_health.rs file:Assistant
Let me look for OpenSearch-related configurations and client initialization:
Assistant
Let me check the analytics module which seems to contain OpenSearch-related code:
Assistant
Now let me check the AppState to understand how the OpenSearch client is initialized and used:
Assistant
(no content)
Assistant
Now I need to understand how the AppState is configured to see how opensearch is initialized. Let me check the app.rs file:
Assistant
Let me continue reading the app.rs file to see where OpenSearch client is initialized:
Assistant
Let me search for initialization code where OpenSearchClient is created:
Assistant
Let me check where AppState is initialized, looking for the main initialization function:
Assistant
Let me check the config files to understand how OpenSearch is configured:
Assistant
Now I can see from line 124 that
opensearchis configured as a setting. Let me now search for the initialization code of AppState to understand how OpenSearch is created:Assistant
Let me check the main lib.rs file to understand how AppState is initialized:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.