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

How to prevent channels with the same name from being created? #1589

Open
1 of 7 tasks
ofmycwt opened this issue Feb 8, 2023 · 10 comments
Open
1 of 7 tasks

How to prevent channels with the same name from being created? #1589

ofmycwt opened this issue Feb 8, 2023 · 10 comments
Labels
auto-triage-skip bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented server-side-issue

Comments

@ofmycwt
Copy link

ofmycwt commented Feb 8, 2023

I expected that 2 calls to conversations.create at the same time would get one of them to fail, but instead 2 channels were created with the same name and different IDs. If I later try to make a 3rd call it fails with name_taken.

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • @slack/types
  • I don't know

Reproducible in:

The Slack SDK version

6.8.1

Node.js runtime version

18.12.1

OS info

ProductName: macOS
ProductVersion: 12.5.1
BuildVersion: 21G83
Darwin Kernel Version 21.6.0

Steps to reproduce:

You can run this code:

		const results = await Promise.all([
			client.conversations.create({token, name: 'duplicated-channel-name2', validate: true}),
			client.conversations.create({token, name: 'duplicated-channel-name2', validate: true})
		]);

and inspect results

Expected result:

An error on one of the calls.

Actual result:

Both calls generated channels with the same name but different IDs. A later third call succeeded again but the fourth failed with name_taken.

Screen Shot 2023-02-08 at 11 52 58

Screen Shot 2023-02-08 at 11 58 30

Requirements

/

@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented and removed untriaged labels Feb 8, 2023
@WilliamBergamin
Copy link
Contributor

Hi @ofmycwt thanks for writing in 🥇 and thanks for the detailed issue!

I have been able to reproduce this on my end as well, it seems to be an unexpected behavior since this does not appear in our other SDKs (tested with deno-slack-sdk)

Here is the script I used to test this, using a User OAuth Token (xoxp-...) with the appropriate scopes (channels:write)

const { WebClient } = require('@slack/web-api');

const run = async () =>{
	const client = new WebClient();
	const results = await Promise.all([
		client.conversations.create({
		  token:
			"xoxp-...",
		  name: "duplicated-channel-name2",
		  validate: true,
		}),
		client.conversations.create({
		  token:
			"xoxp-...",
		  name: "duplicated-channel-name2",
		  validate: true,
		}),
	  ]);
	console.log(results);
}

run();

and this is the output I got

[
  {
    ok: true,
    channel: {
      id: 'C...',
      name: 'duplicated-channel-name2',
      is_channel: true,
      is_group: false,
      is_im: false,
      is_mpim: false,
      is_private: false,
      created: 1675876063,
      is_archived: false,
      is_general: false,
      unlinked: 0,
      name_normalized: 'duplicated-channel-name2',
      is_shared: false,
      is_org_shared: false,
      is_pending_ext_shared: false,
      pending_shared: [],
      context_team_id: 'T...',
      updated: 1675876063681,
      parent_conversation: null,
      creator: 'U...',
      is_ext_shared: false,
      shared_team_ids: [Array],
      pending_connected_team_ids: [],
      is_member: true,
      last_read: '0000000000.000000',
      topic: [Object],
      purpose: [Object],
      previous_names: [],
      priority: 0
    },
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  },
  {
    ok: true,
    channel: {
      id: 'C...',
      name: 'duplicated-channel-name2',
      is_channel: true,
      is_group: false,
      is_im: false,
      is_mpim: false,
      is_private: false,
      created: 1675876063,
      is_archived: false,
      is_general: false,
      unlinked: 0,
      name_normalized: 'duplicated-channel-name2',
      is_shared: false,
      is_org_shared: false,
      is_pending_ext_shared: false,
      pending_shared: [],
      context_team_id: 'T...',
      updated: 1675876063703,
      parent_conversation: null,
      creator: 'U...',
      is_ext_shared: false,
      shared_team_ids: [Array],
      pending_connected_team_ids: [],
      is_member: true,
      last_read: '0000000000.000000',
      topic: [Object],
      purpose: [Object],
      previous_names: [],
      priority: 0
    },
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  }
]

@WilliamBergamin
Copy link
Contributor

Update: we have created an internal issue for this, a patch to the Web API should be coming soon 🥇

@ofmycwt
Copy link
Author

ofmycwt commented Mar 9, 2023

@WilliamBergamin thanks, is there any update on this?

@WilliamBergamin
Copy link
Contributor

Still no update, for the time being I would suggest not using promise.all to create multiple channels and opt for a synchronous approach instead

@nikolaydanekov
Copy link

I have the same issue using Java SDK. We have a microservice architecture with different instances of the SDK, so a patch to the SDK will probably not solve the problem for us.

@github-actions
Copy link

github-actions bot commented May 8, 2023

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@github-actions
Copy link

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@github-actions
Copy link

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

@nitansh11
Copy link

Hey can we please get an update on this. Its still creating multiple channel with same name.

@WilliamBergamin
Copy link
Contributor

There has been no updates for this for this issue, please send a request to prioritize the bug fix to [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-skip bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented server-side-issue
Projects
None yet
Development

No branches or pull requests

5 participants