Skip to content

fix: pin redis to >=7.2,<8.1 to unbreak fresh installs - #295

Closed
galshubeli wants to merge 1 commit into
mainfrom
fix/redis-8.1-connection-kwargs
Closed

fix: pin redis to >=7.2,<8.1 to unbreak fresh installs#295
galshubeli wants to merge 1 commit into
mainfrom
fix/redis-8.1-connection-kwargs

Conversation

@galshubeli

@galshubeli galshubeli commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

Every fresh install fails on the first query:

TypeError: Redis.__init__() got an unexpected keyword argument 'himport_registry'
→ DatabaseUnavailableError: Could not connect to FalkorDB at localhost:6379

ping() still returns True, so health checks pass and the failure only shows up on real work.

Root cause

falkordb's Is_Cluster() — reached while constructing falkordb.asyncio.FalkorDB — copies connection_kwargs off the async pool and forwards them to the synchronous redis.Redis() constructor, which has no **kwargs catch-all:

# falkordb/asyncio/cluster.py
kwargs = pool.connection_kwargs.copy()
info = sync_redis.Redis(**kwargs).info(section="server")

redis 8.1 began injecting pool-internal keys that constructor rejects — five of them: himport_registry, maint_notifications_pool_handler, orig_host_address, orig_socket_timeout, orig_socket_connect_timeout.

Why every install hit this: falkordb used to cap redis and stopped. falkordb 1.4.0 required redis>=7.1.0,<8.0.0; 1.5.0 dropped the upper bound to plain redis>=7.1.0, and 1.6.x still has none — so pip walks forward into whatever redis ships next. There is no current falkordb release that excludes 8.1.0, which is why the constraint has to be expressed here.

Fix

Declare redis>=7.2,<8.1 in dependencies. Metadata only — no source changes.

  • Upper bound <8.1 excludes the broken release. This is the load-bearing half.
  • Lower bound >=7.2 is a second fix: falkordb 1.6 imports redis.driver_info, which does not exist before redis 7.2, so falkordb's declared >=7.1.0 floor is itself unusable. Note this implicitly excludes falkordb <1.5, which required redis<7.0.0.

Verification

End-to-end against a live FalkorDB (connect → create → query → delete graph):

redis result
8.1.0 himport_registry TypeError
8.0.1
8.0.0
7.4.1
7.3.0
7.2.0
7.1.0 ModuleNotFoundError: redis.driver_info

With the pin, pip resolves to redis 8.0.1. Full suite on that resolution: 1098 passed, 40 skipped.

Changes

  • pyproject.tomlredis>=7.2,<8.1, with both bounds explained in a comment.
  • tests/test_connection.py — regression test asserting the invariant rather than a version number: the async pool kwargs must stay constructible by the sync redis.Redis() that Is_Cluster() calls. Covers TLS and non-TLS pools, needs no live server (constructing Redis opens no socket), and fails on redis==8.1.0 with the exact TypeError.
  • CHANGELOG.md — entry under [Unreleased].

Trade-off accepted

This declares redis alongside falkordb, so two packages now constrain it. That is deliberate: the alternative considered was leaving redis undeclared and making the connection layer tolerate 8.1's pool kwargs in code, which would have supported redis 8.1+ but added ~58 lines to core/connection.py. The pin was chosen for the smaller review surface.

Consequence: the SDK is capped below redis 8.1 until the upstream issue is fixed.

Follow-ups (not in this PR)

  • Upstream: Is_Cluster() should filter the kwargs it forwards to the sync constructor, and falkordb should restore an upper bound on redis — dropping it in 1.5.0 is what exposed every downstream consumer to this. Fixing it upstream is what lets this pin's ceiling be lifted.
  • python-dotenv is a dead core dependency — zero imports anywhere in the package, and docs/getting-started.md:60 explicitly tells users to load .env themselves.
  • transformers is imported but declared nowhere (coref_resolvers.py:100), relying on gliner/fastcoref to supply it — the same shape as this redis bug, though guarded by a try/except with a working fallback.

🤖 Generated with Claude Code

The SDK imports redis.asyncio directly but never declared redis as a
dependency, so pip inherited falkordb's redis>=7.1.0 range and resolved
to the newest release. redis 8.1.0 injects an internal himport_registry
key into ConnectionPool.connection_kwargs, and falkordb's Is_Cluster()
forwards those kwargs verbatim to the synchronous redis.Redis()
constructor, which does not accept it:

  TypeError: Redis.__init__() got an unexpected keyword argument
  'himport_registry'

surfaced to callers as DatabaseUnavailableError. ping() still returned
True, so health checks passed and the failure only appeared on the first
real query. Every fresh install from main was affected.

The lower bound is a second fix: falkordb 1.6 imports redis.driver_info,
absent before redis 7.2, so falkordb's declared >=7.1.0 floor was also
unusable.

Verified against a live FalkorDB across redis 7.2.0, 7.3.0, 7.4.1,
8.0.0, 8.0.1 (all pass) and 8.1.0 / 7.1.0 (both fail).

The regression test asserts the invariant rather than a version number:
the async pool kwargs must stay constructible by the sync redis.Redis()
that Is_Cluster() calls, so any future release reintroducing the shape
fails the suite. It requires no live server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

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: af971124-dd60-4169-8f39-588b0a73b39d

📥 Commits

Reviewing files that changed from the base of the PR and between 7f9fd05 and 1e34c45.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • graphrag_sdk/pyproject.toml
  • graphrag_sdk/src/graphrag_sdk/core/connection.py
  • graphrag_sdk/tests/test_connection.py

📝 Walkthrough

Walkthrough

The SDK now filters async-only pool arguments during FalkorDB’s synchronous Redis cluster probe. The arguments are restored after probing. Tests cover TLS, non-TLS, exceptional exits, unknown keys, and pools without connection kwargs.

Changes

Redis 8.1 connection compatibility

Layer / File(s) Summary
Synchronous connection compatibility
graphrag_sdk/src/graphrag_sdk/core/connection.py, graphrag_sdk/pyproject.toml, CHANGELOG.md
The connection code derives supported Redis constructor arguments, hides unsupported pool keys during FalkorDB driver construction, and restores them afterward. Documentation records the fix and dependency ownership.
Pool argument validation
graphrag_sdk/tests/test_connection.py
Tests cover TLS and non-TLS arguments, normal and exceptional restoration, unknown keys, and pools without connection kwargs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: naseem77

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes a Redis version pin, but the changeset implements a code-based compatibility fix without adding that pin. Update the title to describe filtering unsupported Redis pool kwargs during synchronous FalkorDB connection probing.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 fix/redis-8.1-connection-kwargs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@galshubeli
galshubeli requested review from Naseem77 and a lite review from Copilot August 12, 2026 14:03

@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.

🧹 Nitpick comments (2)
graphrag_sdk/tests/test_connection.py (2)

342-346: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the concrete initialization exception.

pytest.raises(Exception) accepts unrelated failures. Assert the DatabaseUnavailableError raised after the patched FalkorDB fails. Match "stop after pool" to keep this helper focused on pool construction.

Proposed test assertion
-        with pytest.raises(Exception):
+        with pytest.raises(DatabaseUnavailableError, match="stop after pool"):
             conn._ensure_client()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@graphrag_sdk/tests/test_connection.py` around lines 342 - 346, Update the
_ensure_client test to expect the concrete DatabaseUnavailableError instead of
the broad Exception, and assert that its message matches "stop after pool" while
retaining the existing pool-construction assertion.

348-358: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add a redis-py version matrix to CI.

The dependency range is redis>=7.2,<8.1, but CI tests only resolver-selected versions. Test redis-py 7.2 and the latest 8.0 release in separate jobs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@graphrag_sdk/tests/test_connection.py` around lines 348 - 358, Add separate
CI jobs for redis-py 7.2 and the latest 8.0 release, explicitly installing each
version within the supported redis>=7.2,<8.1 range before running the relevant
test suite. Keep the existing resolver-selected dependency job unchanged and
ensure both matrix jobs exercise test_sync_redis_accepts_async_pool_kwargs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@graphrag_sdk/tests/test_connection.py`:
- Around line 342-346: Update the _ensure_client test to expect the concrete
DatabaseUnavailableError instead of the broad Exception, and assert that its
message matches "stop after pool" while retaining the existing pool-construction
assertion.
- Around line 348-358: Add separate CI jobs for redis-py 7.2 and the latest 8.0
release, explicitly installing each version within the supported redis>=7.2,<8.1
range before running the relevant test suite. Keep the existing
resolver-selected dependency job unchanged and ensure both matrix jobs exercise
test_sync_redis_accepts_async_pool_kwargs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ea258d8-8149-4f0f-9895-851684737f35

📥 Commits

Reviewing files that changed from the base of the PR and between 70ea2a2 and 7f9fd05.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • graphrag_sdk/pyproject.toml
  • graphrag_sdk/tests/test_connection.py

Copilot AI 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.

Pull request overview

Pins the redis dependency to a known-good range to prevent fresh installs from failing on first query due to a falkordb/redis incompatibility, and adds a regression test to catch future reintroductions of incompatible pool kwarg shapes.

Changes:

  • Declare redis>=7.2,<8.1 as an explicit direct dependency (with rationale for both bounds).
  • Add a regression test asserting that async pool kwargs (after Is_Cluster()-style fixups) remain constructible by sync redis.Redis().
  • Document the install-breakage and the dependency pin in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
graphrag_sdk/pyproject.toml Adds an explicit redis version range to prevent pip resolving to the known-bad 8.1.x line and to enforce a working lower bound.
graphrag_sdk/tests/test_connection.py Introduces a regression test to detect future incompatible kwargs injected into async pool configuration.
CHANGELOG.md Notes the installation breakage and the dependency pin under [Unreleased].

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +350 to +355
import redis as sync_redis
import redis.asyncio as async_redis

kwargs = self._pool_kwargs(ConnectionConfig(ssl=ssl))
# Mirror Is_Cluster()'s own fixups.
kwargs["ssl"] = kwargs.pop("connection_class", None) is async_redis.SSLConnection
Comment thread CHANGELOG.md
Comment on lines +18 to +21
`redis.Redis()` constructor — raising
`TypeError: Redis.__init__() got an unexpected keyword argument
'himport_registry'`, surfaced as `DatabaseUnavailableError`. `ping()`
still succeeded, so health checks passed and the failure only appeared
@galshubeli galshubeli changed the title fix: pin redis to >=7.2,<8.1 to unbreak fresh installs fix: survive redis 8.1's async pool kwargs (no redis pin) Aug 12, 2026
Comment thread graphrag_sdk/tests/test_connection.py Outdated
with pytest.raises(RuntimeError):
with _sync_constructible_pool_kwargs(pool):
raise RuntimeError("probe blew up")
assert pool.connection_kwargs == before
Comment thread graphrag_sdk/tests/test_connection.py Outdated

def test_restores_on_exception(self):
pool = self._build_pool(ConnectionConfig())
before = dict(pool.connection_kwargs)
@galshubeli
galshubeli force-pushed the fix/redis-8.1-connection-kwargs branch from 1e34c45 to 7f9fd05 Compare August 12, 2026 14:31
@galshubeli galshubeli changed the title fix: survive redis 8.1's async pool kwargs (no redis pin) fix: pin redis to >=7.2,<8.1 to unbreak fresh installs Aug 12, 2026
@galshubeli galshubeli closed this Aug 12, 2026
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