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

Event triggered by unknown workspace #2145

Closed
kronosapiens opened this issue Jun 22, 2024 · 3 comments
Closed

Event triggered by unknown workspace #2145

kronosapiens opened this issue Jun 22, 2024 · 3 comments
Assignees
Labels
auto-triage-stale question M-T: User needs support to use the project

Comments

@kronosapiens
Copy link

kronosapiens commented Jun 22, 2024

@slack/bolt version

^3.17.0

Your App and Receiver Configuration

const app = new App({
  logLevel: LogLevel.WARN,
  signingSecret: process.env.CHORES_SIGNING_SECRET,
  clientId: process.env.CHORES_CLIENT_ID,
  clientSecret: process.env.CHORES_CLIENT_SECRET,
  stateSecret: process.env.STATE_SECRET,
  customRoutes: [ common.homeEndpoint('Chores') ],
  scopes: [
    'channels:history',
    'channels:join',
    'chat:write',
    'commands',
    'groups:history',
    'users:read',
  ],
  installationStore: {
    storeInstallation: async (installation) => {
      await Admin.addHouse(installation.team.id, installation.team.name); # team_id stored in the DB
      await Admin.updateHouseConf(installation.team.id, CHORES_CONF, { oauth: installation });
      console.log(`chores installed @ ${installation.team.id}`);
    },
    fetchInstallation: async (installQuery) => {
      ({ choresConf } = (await Admin.getHouse(installQuery.teamId)));
      return choresConf.oauth;
    },
    deleteInstallation: async (installQuery) => {
      await Admin.updateHouseConf(installQuery.teamId, CHORES_CONF, { oauth: null });
      console.log(`chores uninstalled @ ${installQuery.teamId}`);
    },
  },
  installerOptions: { directInstall: true },
});

Node.js runtime version

^20.11.0

More information:

Original issue here.

I am seeing the following error in my logs:

chores user_change

[ERROR]  bolt-app error: insert into "Resident" ("activeAt", "exemptAt", "houseId", "slackId") values ($1, $2, $3, $4)
  detail: 'Key (houseId)=(E011XGDUJMC) is not present in table "House".', 

This is caused by the app receiving the user_change event for a workspace (E011XGDUJMC) which is not stored in the database. This is surprising, as it is unclear why the app is receiving an event from a workspace which has never installed the app. The main clue is the leading character of the identifier - E - suggests that this is not a typical workspace. Perhaps this is some feature of Enterprise which I am unaware of?

Would be curious to resolve the issue. Thanks!

@hello-ashleyintech hello-ashleyintech self-assigned this Jun 24, 2024
@hello-ashleyintech hello-ashleyintech added question M-T: User needs support to use the project and removed untriaged labels Jun 24, 2024
@hello-ashleyintech
Copy link
Contributor

hello-ashleyintech commented Jun 24, 2024

Hi, @kronosapiens! 👋 Thanks for submitting this issue!

Based on the description provided, it sounds like your issue could be due to grid migration. I would recommend using one of (or even better, both!) of the following approaches:

  • Use the auth.test API to maintain the enterprise_id / team_id in your installation store database
  • Detect the migration event using the Events API

I hope this helps - let me know if you have further questions! 😄

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.

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-stale question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants