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

enterprise_id in InstallationQuery can be invalid for Slack Connect channel events #935

Closed
4 of 10 tasks
seratch opened this issue May 27, 2021 · 0 comments
Closed
4 of 10 tasks
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor
Milestone

Comments

@seratch
Copy link
Member

seratch commented May 27, 2021

Bug Report

tl;dr - The fix for #687 was not complete for the events that happen in a Slack Connect channel shared among an Enterprise Grid workspace and non-Enterprise Grid workspace.

In a Slack Connect shared channel, the enterprise_id / team_id to use is always under the authorizations[0]. For instance, the following event is coming from workspace: T_this_non_grid_workspace, which is not in an Enterprise Grid.

{
  "team_id": "T_connected_grid_workspace",
  "enterprise_id": "E_org_id",
  "api_app_id": "A111",
  "event": {
    "type": "message",
    "text": ":wave: Hi, this is my first message in a Slack Connect channel!",
    "user": "U111",
    "ts": "1622099033.001500",
    "team": "T_this_non_grid_workspace",
    "channel": "C111",
    "channel_type": "channel"
  },
  "type": "event_callback",
  "authorizations": [
    {
      "enterprise_id": null,
      "team_id": "T_this_non_grid_workspace",
      "user_id": "U_authed_user",
      "is_bot": true,
      "is_enterprise_install": false
    }
  ],
  "is_ext_shared_channel": true,
  "event_context": "2-message-T_connected_grid_workspace-A111-C111"
}

In this case, the argument for installationStore#fetchInstallation includes an invalid enterprise_id.

const app = new App({
  developerMode: true,
  socketMode: true,
  appToken: process.env.SLACK_APP_TOKEN,
  logLevel: process.env.SLACK_LOG_LEVEL || LogLevel.DEBUG,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  clientId: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET,
  stateSecret: 'my-state-secret',
  scopes: ['commands', 'chat:write'],
  installationStore: {
    storeInstallation: async (installation) => {
      // TODO
    },
    fetchInstallation: async (installQuery) => {
      console.log(installQuery);
      // TODO
    },
  },
});

The console.log(installQuery); prints the following:

{
  userId: 'U111',
  isEnterpriseInstall: false,
  teamId: 'T_this_non_grid_workspace',
  enterpriseId: 'E_org_id',
  conversationId: 'C111'
}

The enterpriseId must be null.

Reproducible in:

any version

node version:

any

Steps to reproduce:

  1. Create a workspace that is not in an Enterprise Grid (T_this_non_grid_workspace)
  2. Create a Slack Connect channel with a workspace in an Enterprise Grid (T_connected_grid_workspace)
  3. Install your Slack app that subscribes message events to the T_this_non_grid_workspace workspace
  4. Add the app to the Slack Connect channel
  5. See the installationQuery in fetchInstallation method

Expected result:

The enterpriseId is null

Actual result:

The T_connected_grid_workspace workspace's enterprise_id is set.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.
@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor labels May 27, 2021
@seratch seratch added this to the 3.4.0 milestone May 27, 2021
@seratch seratch self-assigned this May 31, 2021
seratch added a commit to seratch/bolt-js that referenced this issue May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor
Projects
None yet
Development

No branches or pull requests

1 participant