Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hdbikeroh opened this issue Mar 29, 2025 · 4 comments

Comments

@hdbikeroh
Copy link

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

@ericmeadows
Copy link

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

@carltongibson
Copy link
Member

Thanks for the report.

Follows from:
django/channels#2122

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

@carltongibson
Copy link
Member

OK, so started a draft in #410.

@carltongibson
Copy link
Member

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 carltongibson marked this as a duplicate of #411 Apr 3, 2025
@carltongibson carltongibson changed the title Channels 4.2.1 now reaches invalid code in channels_redis 4.2.1: AttributeError: 'RedisChannelLayer' object has no attribute 'valid_channel_name'. Deprecation warning for valid_group_name method. AttributeError: 'RedisChannelLayer' object has no attribute 'valid_channel_name'. Apr 3, 2025
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

No branches or pull requests

3 participants