Skip to content

Installation queries use enterpriseId even when not an enterprise install #14

Description

@omermizr

The problem

Our app stops working for organizations that upgrade to Enterprise Grid.

The cause

This happens when an organization installs an app before they have an enterprise plan (where InstallationQuery.enterprise doesn't exist), and then upgrade to an enterprise plan (where InstallationQuery.enterprise does exist).
In that scenario, a previously stored installation wouldn't have the enterpriseId field, but new requests (events, actions etc.) will have the enterprise object on the InstallationQuery, so fetchInstallation won't find it.

The solution(?)

I think it would make sense to only use enterpriseId when isEnterpriseInstall is false, but I don't know all the considerations intimately like @seratch does. For Mongoose, where the queries are made against a single string field (__appOrgWorkspace__, see here:

where[this.searchColumnNameForApp] = `${this.clientId}:${query.enterpriseId}:${teamId}`;
) this will probably require a DB migration to work properly for existing installations (or more complex code to query by regex and filter in JS or something similar).
For us, we have previously ported one of the packages here so we can just make a change in our codebase, but we wanted to be good Samaritans and report this, and also get feedback.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions