Skip to content

fix: upgrade to elasticsearch-py 7.17.13 and opensearch-py 2.x for urllib3 2.x compatibility - #118

Merged
dpgaspar merged 1 commit into
masterfrom
danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2
Feb 6, 2026
Merged

fix: upgrade to elasticsearch-py 7.17.13 and opensearch-py 2.x for urllib3 2.x compatibility#118
dpgaspar merged 1 commit into
masterfrom
danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2

Conversation

@dpgaspar

@dpgaspar dpgaspar commented Feb 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Upgrades elasticsearch-py to >=7.17.13, <8 which supports urllib3 2.x on Python 3.10+, resolving connection failures on modern Python environments
  • Adds opensearch-py>=2.4.0, <3 as a direct dependency for OpenSearch support
  • Updates CI to test against all three backends: ES 7.x, ES 8.x (via compatibility mode with ELASTIC_CLIENT_APIVERSIONING=1), and OpenSearch 2.x
  • Updates SQLAlchemy integration to 2.x API (URL.create, text(), import_dbapi(), ReflectedColumn, etc.)
  • Requires Python 3.10+ (drops 3.6–3.9)

Changes

Dependencies (setup.py, requirements-dev.txt)

  • elasticsearch>=7.17.13, <8 (was >=7.x, <7.14)
  • opensearch-py>=2.4.0, <3 (new direct dependency)
  • Pinned dev dependencies matching modern toolchain

Core (es/baseapi.py, es/elastic/api.py, es/opendistro/api.py)

  • Dual exception handling for both elasticsearch and opensearchpy exceptions
  • Conditional Content-Type header: ES 7.x client needs explicit header, OpenSearch client sets it automatically
  • Filter cursor-specific params (sql_path, fetch_size, time_zone, v2) from client kwargs
  • Class-level type annotations for self.es in Connection subclasses

SQLAlchemy (es/basesqlalchemy.py, es/elastic/sqlalchemy.py, es/opendistro/sqlalchemy.py)

  • Added import_dbapi() classmethod on all dialect classes (SA 2.x requirement)
  • supports_statement_cache = False
  • get_type() returns TypeEngine instances (not classes)
  • get_columns() returns List[ReflectedColumn]

Tests & CI

  • SQLAlchemy 2.x test API: URL.create(), text(), inspect(), autoload_with=
  • CI matrix tests against ES 7.17.27, ES 8.17.0, and OpenSearch 2.19.0
  • Docker Compose updated with all three services

Test plan

  • 48/48 tests pass on ES 7.17.27
  • 48/48 tests pass on ES 8.17.0 (compatibility mode)
  • 48/48 tests pass on OpenSearch 2.19.0
  • Linting passes: black, flake8, mypy (8 pre-existing errors, 0 new)
  • CI pipeline passes on GitHub Actions

🤖 Generated with Claude Code

@dpgaspar
dpgaspar force-pushed the danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2 branch 2 times, most recently from 179aa72 to cfac610 Compare February 5, 2026 12:36
@dpgaspar
dpgaspar force-pushed the danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2 branch 2 times, most recently from 00c1b37 to 6120362 Compare February 5, 2026 12:41
@dpgaspar
dpgaspar force-pushed the danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2 branch 3 times, most recently from 2012aa1 to c2799af Compare February 6, 2026 10:22
…llib3 2.x compatibility

Upgrades elasticsearch-dbapi to support modern Python environments (3.10+)
by using elasticsearch-py 7.17.13 (urllib3 2.x compatible) and adding
opensearch-py 2.x as a direct dependency. Supports ES 7.x natively,
ES 8.x via compatibility mode, and OpenSearch 2.x simultaneously.
Updates SQLAlchemy integration to 2.x API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dpgaspar
dpgaspar force-pushed the danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2 branch from c2799af to 22cb494 Compare February 6, 2026 12:26
@dpgaspar
dpgaspar merged commit 82c56c5 into master Feb 6, 2026
4 checks passed
@dpgaspar
dpgaspar deleted the danielgaspar/sc-97626/unable-to-connect-to-elasticsearch2 branch February 6, 2026 12:35
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.

2 participants