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

FastAPI & sqlalchemy - Your installation with this app is no longer available #1030

Closed
kadosh1000 opened this issue Feb 20, 2024 · 2 comments
Labels
area:async bug Something isn't working docs Improvements or additions to documentation

Comments

@kadosh1000
Copy link

kadosh1000 commented Feb 20, 2024

I am trying to use bolt-python asyncly using FastAPI and sqlalchemy (using Postgres).
I basically took this sqlalchemy example and just replaced Sanic with FastAPI.

Installation and redirect works well, and I also see the installations being added to Postgres, and I can also see events coming in through ngrok. But the events are not being processed and instead I get the message:

We apologize, but for some unknown reason, your installation with this app is no longer available. Please reinstall this app into your workspace.

I tried reinstalling the app to the workspace multiple times, but I still continue to get this error.

I also tried debugging the AsyncInstallationStore and it seems that the async_find_bot function never triggers, so I am not sure where exactly to look why its not getting there.

Edit:
After some more digging into the code, it seems to be probably related to the AsyncInstallationStoreAuthorize. It looks like it is trying to use async_find_installation even though it was not implemented by my installation store, probably because it is extending AsyncInstallationStoreclass. Anyway to go around it?

Reproducible in:

The slack_bolt version

slack-bolt==1.18.1
slack_sdk==3.27.0

Python runtime version

3.10.12

OS info

ProductName: macOS
ProductVersion: 13.4.1
ProductVersionExtra: (c)
BuildVersion: 22F770820d
Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64

Steps to reproduce:

  1. Copy the sqlalchemy example
  2. Replace Sanic with FastAPI
  3. Set relevant environment variables (Client ID, Client Secret, Signing Secret)
  4. Install the app to your slack workspace using /slack/install
  5. Send a message to the bot on Slack

Expected result:

The event should go through the request handler and trigger the relevant event handle (i.e @app.event("message"))

Actual result:

When an event is being sent to the app using POST /slack/events, it responds with 200 with the message:

We apologize, but for some unknown reason, your installation with this app is no longer available. Please reinstall this app into your workspace.

image

Also I can see this error in my console:
Although the app should be installed into this workspace, the AuthorizeResult (returned value from authorize) for it was not found.

@kadosh1000
Copy link
Author

Ok, so I found the issue and the steps to fix it.
There were 2 issues with just copy-pasting the example:

  1. if using the find_bot function instead of find_installlation then you should put to the app properties installation_store_bot_only=True

  2. Apparently there was an exception thrown because my implementation of AsyncInstallationStore:async_find_bot function, did not have the is_enterprise_install optional parameter. So the function signature will look like:
    async def async_find_bot( self, *, enterprise_id: Optional[str], team_id: Optional[str], is_enterprise_install: Optional[bool] ) -> Optional[Bot]:

I recommend to update the examples using custom AsyncInstallationStore

seratch added a commit that referenced this issue Feb 26, 2024
@seratch seratch added bug Something isn't working docs Improvements or additions to documentation area:async labels Feb 26, 2024
@seratch
Copy link
Member

seratch commented Feb 26, 2024

Thank you so much for reporting the issue, and we're sorry for the disruption you encountered. I just updated the example code to resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:async bug Something isn't working docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants