channels_redis icon indicating copy to clipboard operation
channels_redis copied to clipboard

Deprecation warning for valid_group_name method. AttributeError: 'RedisChannelLayer' object has no attribute 'valid_channel_name'.

Open hdbikeroh opened this issue 8 months ago • 4 comments

Problem started occurring with channels==4.2.1

  File "/code/dealer/daemon/handlers/player_channel_handler.py", line 21, in send_to_channel
    async_to_sync(layer.send)(channel_dest, new_message)
  File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 254, in __call__
    return call_result.result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 331, in main_wrap
    result = await self.awaitable(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/channels_redis/core.py", line 172, in send
    assert self.valid_channel_name(channel), "Channel name not valid"
           ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'RedisChannelLayer' object has no attribute 'valid_channel_name'. Did you mean: 'valid_channel_names'?

The specific line in channels_redis/core.py line 172 references an missing method

This logic isn't invoked using channels==4.2.0 but got uncovered with channels==4.2.1

hdbikeroh avatar Mar 29 '25 20:03 hdbikeroh

Thanks for filing this - it brought down our production system!!

ericmeadows avatar Mar 29 '25 23:03 ericmeadows

Thanks for the report.

Follows from: https://github.com/django/channels/pull/2122

Valid channels/group name methods will need updating to use the new require prefix.

carltongibson avatar Mar 30 '25 05:03 carltongibson

OK, so started a draft in #410.

carltongibson avatar Mar 30 '25 07:03 carltongibson

Channels 4.2.2 adds (deprecated) fallbacks for the old methods, so we can resolve this without rushing.

https://pypi.org/project/channels/4.2.2/

carltongibson avatar Mar 30 '25 15:03 carltongibson