FastAPI & sqlalchemy - Your installation with this app is no longer available
kadosh1000 opened this issue · comments
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 AsyncInstallationStore
class. 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:
- Copy the sqlalchemy example
- Replace
Sanic
withFastAPI
- Set relevant environment variables (Client ID, Client Secret, Signing Secret)
- Install the app to your slack workspace using
/slack/install
- 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.
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.
Ok, so I found the issue and the steps to fix it.
There were 2 issues with just copy-pasting the example:
-
if using the
find_bot
function instead offind_installlation
then you should put to the app propertiesinstallation_store_bot_only=True
-
Apparently there was an exception thrown because my implementation of
AsyncInstallationStore:async_find_bot
function, did not have theis_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
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.