Skip to content

Conversation

@vchomakov
Copy link

@vchomakov vchomakov commented Dec 23, 2025

This PR adds client identification to Redis connections created by Flask-Session, allowing Redis operators to see which library is connecting to their servers.

Redis servers support the lib_name and lib_version parameters (introduced in redis-py) to help operators identify which upstream libraries are connecting. This improves observability and debugging for Redis operators.

Following redis-py best practices, lib_name and lib_version identify the upstream library (Flask-Session) rather than redis-py itself.

Implementation

  • Added get_flask_session_version() utility function to retrieve the Flask-Session version using importlib.metadata with fallback to __version__
  • Added get_redis_py_version() utility function to retrieve the redis-py version
  • Added add_redis_version_info() utility function to set lib_name="redis-py(flask-session_v<version>)" and lib_version=<redis-py-version>
  • Updated RedisSessionInterface.__init__() to call add_redis_version_info()
  • Only sets these parameters if not already provided by the user, ensuring user-provided values are never overridden

ReadTheDocs Configuration Fix

This PR also fixes the missing Sphinx configuration in .readthedocs.yaml that was causing all documentation builds to fail:

  • Added configuration: docs/conf.py to the sphinx section
  • This key is now required by ReadTheDocs (see their blog post)
  • This fix unblocks documentation builds for this PR and all future contributions

Testing

  • Added unit tests in tests/test_redis.py to verify version identification behavior
  • Tests verify that custom lib_name and lib_version values are respected and not overridden
  • All existing tests pass

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Run pytest and tox, no tests failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant