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

FIX: Allow several chat channels to have an empty slug #25680

Conversation

AndrewPrigorshnev
Copy link
Contributor

@AndrewPrigorshnev AndrewPrigorshnev commented Feb 14, 2024

In certain cases, chat channels may have empty slugs, it happens when:

  1. The slug_generation_method setting is set to None
  2. slug_generation_method is set to ASCII and a channel with a Unicode name and an empty slug is created (in this case, the code that creates channels tries to generate a slug and fallbacks to an empty slug)

At the moment, we have a unique index on the chat_channels.slug column which leads to errors when creating several channels with empty slugs (Discourse is able to create one such channel, but when trying to create the second one fails because of the unique constraint). This PR fixes that by adding a where condition to the index. Slugs still have to be unique, but now many channels may have empty slugs.

This fix is similar to the one we've made to the category slugs – 7ba914f.

@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label Feb 14, 2024
@AndrewPrigorshnev AndrewPrigorshnev changed the title FIX: Error when creating a chat channel with a unicode name FIX: Allow several channels to have an empty slug Feb 14, 2024
@AndrewPrigorshnev AndrewPrigorshnev changed the title FIX: Allow several channels to have an empty slug FIX: Allow several chat channels to have an empty slug Feb 14, 2024
@AndrewPrigorshnev AndrewPrigorshnev force-pushed the fix/error-when-creating-a-chat-channel-with-a-unicode-name branch 2 times, most recently from 5e6c302 to b16166a Compare February 14, 2024 19:51
@AndrewPrigorshnev AndrewPrigorshnev force-pushed the fix/error-when-creating-a-chat-channel-with-a-unicode-name branch from b16166a to a5380e6 Compare February 14, 2024 19:59
@AndrewPrigorshnev AndrewPrigorshnev marked this pull request as ready for review February 14, 2024 20:31
@jjaffeux
Copy link
Contributor

Nice catch

@AndrewPrigorshnev AndrewPrigorshnev merged commit e83d8fb into main Feb 14, 2024
18 checks passed
@AndrewPrigorshnev AndrewPrigorshnev deleted the fix/error-when-creating-a-chat-channel-with-a-unicode-name branch February 14, 2024 20:39
renato pushed a commit to renato/discourse that referenced this pull request Feb 29, 2024
In certain cases, chat channels may have empty slugs, it happens when:

1. The `slug_generation_method` setting is set to `None`
2. `slug_generation_method` is set to `ASCII` and a channel with 
a Unicode name and an empty slug is created (in this case, the code 
that creates channels tries to generate a slug and fallbacks to an empty slug)

At the moment, we have a unique index on the `chat_channels.slug` column 
which leads to errors when creating several channels with empty slugs 
(Discourse is able to create one such channel, but when trying to create 
the second one fails because of the unique constraint). This PR fixes that 
by adding a `where` condition to the index. Slugs still have to be unique, 
but now many channels may have empty slugs.

This fix is similar to the one we made to the category slugs – discourse@7ba914f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
2 participants