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

Ticket creation is failing in a fresh installation #3343

Closed
vikassinha2019 opened this issue May 2, 2023 · 5 comments
Closed

Ticket creation is failing in a fresh installation #3343

vikassinha2019 opened this issue May 2, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@vikassinha2019
Copy link

Hi,

We are testing the latest release v20230409. The ticket creation is failing at slack contact resolver. We have configured both Slack Contact and Conversation plugin in this instance.
When creating an incident, following error trace is showing up.

ERROR:dispatch.main:'email'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/dispatch/main.py", line 185, in dispatch
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 108, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/main.py", line 176, in dispatch
    raise e from None
  File "/usr/local/lib/python3.11/site-packages/dispatch/main.py", line 168, in dispatch
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.11/site-packages/sentry_asgi/middleware.py", line 22, in __call__
    raise exc from None
  File "/usr/local/lib/python3.11/site-packages/sentry_asgi/middleware.py", line 19, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 108, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/main.py", line 144, in db_session_middleware
    raise e from None
  File "/usr/local/lib/python3.11/site-packages/dispatch/main.py", line 142, in db_session_middleware
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 165, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/incident/views.py", line 124, in create_incident
    incident = create(db_session=db_session, incident_in=incident_in)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/incident/service.py", line 205, in create
    participant_flows.add_participant(
  File "/usr/local/lib/python3.11/site-packages/dispatch/participant/flows.py", line 34, in add_participant
    individual = individual_service.get_or_create(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/individual/service.py", line 91, in get_or_create
    individual_info = contact_plugin.instance.get(email, db_session=db_session)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/decorators.py", line 123, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/decorators.py", line 106, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dispatch/plugins/dispatch_slack/plugin.py", line 275, in get
    "email": profile["email"],
             ~~~~~~~^^^^^^^^^
KeyError: 'email'
INFO:     172.19.0.1:48440 - "POST /default/incidents HTTP/1.1" 500 Internal Server Error

We have cross checked the Slack configuration in Dispatch. It is correct.

@vikassinha2019 vikassinha2019 changed the title Ticket creation is failing in fresh installation Ticket creation is failing in a fresh installation May 2, 2023
@wssheldon
Copy link
Contributor

Thanks for reporting this. Take a look at this note in the Slack documentation related to the API endpoint this code uses:

https://api.slack.com/methods/users.profile.get#email-addresses

Screenshot 2023-05-02 at 2 49 54 PM

Does this resolve the issue?

@vikassinha2019
Copy link
Author

vikassinha2019 commented May 3, 2023

The bot that I am using do have these permissions. But am still facing this issue. Following are the scopes authorised.

bookmarks:write
channels:history
channels:manage
channels:read
chat:write
commands
files:read
groups:history
groups:read
groups:write
im:history
im:read
im:write
mpim:history
mpim:read
mpim:write
pins:write
reactions:read
reactions:write
reminders:write
remote_files:read
remote_files:share
remote_files:write
team:read
usergroups:read
usergroups:write
users.profile:read
users:read
users:read.email
users:write

@wssheldon
Copy link
Contributor

Just to confirm, the Email Display setting is checked in your Slack Admin settings as well? If so, could you share an example output of what the profile dictionary you receive is? That will help a lot to troubleshoot this. Otherwise, I have a fix ready for this issue that I'll merge tomorrow: #3344

@wssheldon wssheldon added the bug Something isn't working label May 3, 2023
@wssheldon wssheldon self-assigned this May 3, 2023
@vikassinha2019
Copy link
Author

Unfortunately, I dont have admin access on our Slack space. However, I can verify that as a normal user, I can see email address of other users form their profile in slack.
Here is the masked output from users.info api test for your reference:

Screenshot 2023-05-03 at 3 11 58 PM

@vikassinha2019
Copy link
Author

Thanks. Issue is resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants