Skip to content

Check Redis server before hash field TTL#841

Open
sakshichitnis27 wants to merge 1 commit into
redis:mainfrom
sakshichitnis27:fix/829-server-hash-expiration-check
Open

Check Redis server before hash field TTL#841
sakshichitnis27 wants to merge 1 commit into
redis:mainfrom
sakshichitnis27:fix/829-server-hash-expiration-check

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #829

Summary

Check the connected Redis server version before using hash field expiration commands. This prevents HashModel.save() from calling HTTL on Redis versions older than 7.4.

Added regression tests for supported and unsupported server versions.

Testing

  • Verified the fix against Redis 7.2.14
  • pytest -q -n auto ./tests/ ./tests_sync/

Fixes #829


Note

Medium Risk
Changes persistence paths for HashModel saves and field TTL APIs; behavior shifts on Redis < 7.4 (skips HTTL/HEXPIRE) but avoids runtime errors—worth verifying against production Redis versions.

Overview
Hash field expiration (HTTL / HEXPIRE on HashModel.save() and related APIs) is now gated on the connected Redis server version, not only redis-py ≥ 5.1.0. supports_hash_field_expiration(conn) is async, takes a connection, and returns false unless INFO server reports Redis 7.4+; failures from Redis or parsing are swallowed and treated as unsupported.

HashModel.save() and expire_field / field_ttl / persist_field await that check with self.db() so older servers (e.g. 7.2) no longer hit unsupported commands during ordinary saves. Tests add parametrized server-version coverage and update the existing support probe to pass the fixture client.

Reviewed by Cursor Bugbot for commit 35caf69. Bugbot is set up for automated code reviews on this repo. Configure here.

@sakshichitnis27

Copy link
Copy Markdown
Author

Hi maintainers,
I’ve opened PR #841 to address this issue. Please let me know if any changes or additional tests are needed. I’d be happy to update it. Thanks!

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.

HashModel.save() crashes with unknown command 'HTTL' on Redis < 7.4 when redis-py ≥ 5.1.0

1 participant