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

When group name is too long, don't raise TypeError #1845

Open
nerdoc opened this issue May 13, 2022 · 4 comments · May be fixed by #2122
Open

When group name is too long, don't raise TypeError #1845

nerdoc opened this issue May 13, 2022 · 4 comments · May be fixed by #2122

Comments

@nerdoc
Copy link

nerdoc commented May 13, 2022

Using channels==3.0.4 (and channels_redis==3.4.0, turbo-django==0.4.2), somehow group names with 118 chars are created, I dont know why (another bug somewhere).
But channels gives me:

  File "/.../.venv/lib/python3.10/site-packages/asgiref/sync.py", line 270, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "/.../.venv/lib/python3.10/site-packages/channels_redis/core.py", line 668, in group_send
    assert self.valid_group_name(group), "Group name not valid"
  File "/.../.venv/lib/python3.10/site-packages/channels/layers.py", line 165, in valid_group_name
    raise TypeError(
TypeError: Group name ('WyJwcmVzY3JpcHRpb25zOk5ld1ByZXNjcmlwdGlvbnNCYWRnZUNvbXBvbmVudCIsWzJdLHt9XQ...PS0yfqaffBmQzpnXc56fhdzI5N68jOBhHDqtQIJEbUI') must be a valid unicode string containing only ASCII alphanumerics, hyphens, or periods.

See here and following lines.

I had a hard time finding out that the length of the group name was the problem, and not the (ASCII) type.
Maybe you could just add a hint like

        raise TypeError(
            "Group name must be a valid unicode string containing only ASCII "
            + "alphanumerics, hyphens, or periods, and max. 99 characters."
        )
@nerdoc
Copy link
Author

nerdoc commented May 13, 2022

Oh, and the 99 characters are a bit, eh,. random? Why not 128?

@carltongibson
Copy link
Member

We could change there to use validators and raise an appropriate error.

@nerdoc
Copy link
Author

nerdoc commented May 13, 2022

Definitely better idea!

@IronJam11 IronJam11 linked a pull request Jan 10, 2025 that will close this issue
@IronJam11
Copy link

hey, I made the necessary minor change. Please let me know if there are further corrections that I will have to make

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 a pull request may close this issue.

3 participants