Skip to content

Fix ElasticSearch UnsupportedProductError#994

Merged
pragya811 merged 2 commits into
mainfrom
es_error
May 4, 2026
Merged

Fix ElasticSearch UnsupportedProductError#994
pragya811 merged 2 commits into
mainfrom
es_error

Conversation

@pragya811

@pragya811 pragya811 commented May 4, 2026

Copy link
Copy Markdown
Member

Type of change

Note: Fill x in []

  • bug
  • enhancement
  • documentation
  • dependencies

Description

The elasticsearch-py 7.14+ client introduced a product verification check that rejects connections to non-Elasticsearch servers. Since we connect to OpenSearch 1.2.4, the client throws UnsupportedProductError on the first request (ping()), preventing all data uploads.

Fix : Bypass the product verification by setting transport._verified_elasticsearch = True immediately after client initialization, before any requests are made. This skips the server product check while preserving all existing client functionality.

For security reasons, all pull requests need to be approved first before running any automated CI

Summary by CodeRabbit

  • Bug Fixes
    • Improved Elasticsearch/OpenSearch client compatibility.
    • Added graceful handling during client initialization; emits a warning when certain client verification details are unavailable to avoid failures.

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 232625b7-e28a-40db-876e-b1d7be8d04b5

📥 Commits

Reviewing files that changed from the base of the PR and between 66857ba and 2ed77cc.

📒 Files selected for processing (1)
  • cloud_governance/common/elasticsearch/elasticsearch_operations.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • cloud_governance/common/elasticsearch/elasticsearch_operations.py

📝 Walkthrough

Walkthrough

Elasticsearch client initialization in ElasticSearchOperations.__init__ now attempts to set the transport's internal _verified_elasticsearch flag to True after client creation, with an AttributeError caught and logged; no public signatures changed.

Changes

Elasticsearch Client Initialization

Layer / File(s) Summary
Client Construction
cloud_governance/common/elasticsearch/elasticsearch_operations.py
Existing code constructs the Elasticsearch client and assigns it to self.__es.
Post-init Transport Patch
cloud_governance/common/elasticsearch/elasticsearch_operations.py
After construction, code tries to set self.__es.transport._verified_elasticsearch = True when the attribute exists to bypass product verification.
Error Handling / Logging
cloud_governance/common/elasticsearch/elasticsearch_operations.py
The assignment is wrapped in try/except AttributeError and logs a warning if the attribute is absent.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A whisker-quick tweak, one boolean true,
I hopped in the code and made the wires new.
No signatures harmed, just a gentle cheer,
Elasticsearch and friends now draw near. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing an ElasticSearch UnsupportedProductError that occurs when connecting to OpenSearch. It accurately reflects the bug being resolved.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch es_error

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cloud_governance/common/elasticsearch/elasticsearch_operations.py`:
- Around line 57-58: The code unconditionally writes to the private field
self.__es.transport._verified_elasticsearch which can be absent in other
elasticsearch-py versions and currently lives inside a broad except that sets
self.__es = None; instead, guard that write by checking hasattr(self, "__es")
and hasattr(self.__es, "transport") and hasattr(self.__es.transport,
"_verified_elasticsearch") (or wrap only that assignment in a try/except
AttributeError), and on failure log a warning with the exception details (do not
set self.__es = None there). Narrow the broad exception handling around client
creation/connection so only real connection/creation failures set self.__es =
None, and keep the private-attribute override isolated and safely handled in the
method where self.__es is initialized/modified.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 430bd23a-1e74-4700-b011-8495625b8eda

📥 Commits

Reviewing files that changed from the base of the PR and between b25434c and 66857ba.

📒 Files selected for processing (1)
  • cloud_governance/common/elasticsearch/elasticsearch_operations.py

Comment thread cloud_governance/common/elasticsearch/elasticsearch_operations.py Outdated
@ebattat

ebattat commented May 4, 2026

Copy link
Copy Markdown
Member

@pragya811, I will aproved it but we should ask @inntran to upgrade OpenSearch version to support elasticsearch 8/9 versions.

@ebattat ebattat requested review from ebattat and inntran May 4, 2026 09:59
@ebattat ebattat added the bug Something isn't working label May 4, 2026

@ebattat ebattat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/approved

@pragya811 pragya811 merged commit a05908a into main May 4, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Cloud-Governance project May 4, 2026
@pragya811 pragya811 deleted the es_error branch May 5, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants