-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
After upgrading to redis-py 7.2.0 (released Feb 16, 2026), any Redis operations using Unix domain socket connections crash with:
AttributeError: 'UnixDomainSocketConnection' object has no attribute 'port'
Seems like a regression introduced by the new OpenTelemetry native metrics support added in #3954. The OTel instrumentation added accesses conn.host and conn.port unconditionally when recording metrics:
# redis/client.py - multiple locations
record_operation_duration(
command_name=command_name,
duration_seconds=time.monotonic() - start_time,
server_address=conn.host,
server_port=conn.port, # <-- AttributeError for UnixDomainSocketConnection - no port attribute
db_namespace=str(conn.db),
)Environment
- Redis server listening on a Unix socket (not TCP)
- redis-py 7.2.0
- Execute any Redis command (e.g.,
PING)
Reproduction Script
Here's the Python script to reproduce the issue:
"""
Requirements:
- Redis server running with: redis-server --unixsocket /tmp/redis-test.sock --unixsocketperm 777 --port 0 --daemonize yes
- redis-py 7.2.0: pip install redis==7.2.0
"""
import redis
def main():
r = redis.Redis(
unix_socket_path='/tmp/redis-test.sock',
encoding='utf-8',
decode_responses=True
)
print(f'redis-py version: {redis.__version__}')
print(f'Connection class: {r.connection_pool.connection_class.__name__}')
print()
print('Executing PING command...')
# This triggers _execute_command() which crashes at line 748:
# server_port=conn.port, # AttributeError!
result = r.ping()
print(f'Result: {result}')
if __name__ == '__main__':
main()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels