revelrylabs / slax

Elixir Slack slash command handler
MIT License
14 stars 7 forks source link

Bug - issue lookup fails for repos named "platform" #450

Closed grossvogel closed 2 months ago

grossvogel commented 2 months ago

Description

Running hunitip/platform#... in the #hunit channel fails, while hunitip/word-addin#... succeeds. Judging from the error message, it seems that there's an invalid assumption being made that each repo name only appears once in the DB. So revelry platform and hunit platform collide. This seems to have broken lookups in #platform as well.

2024-08-27T18:24:45.071526+00:00 app[web.1]: 18:24:45.070 [error] GenServer #PID<0.3917.0> terminating
2024-08-27T18:24:45.071540+00:00 app[web.1]: ** (Ecto.MultipleResultsError) expected at most one result but got 2 in query:
2024-08-27T18:24:45.071540+00:00 app[web.1]:
2024-08-27T18:24:45.071541+00:00 app[web.1]: from p0 in Slax.ProjectRepo,
2024-08-27T18:24:45.071542+00:00 app[web.1]: where: p0.repo_name == ^"platform"
2024-08-27T18:24:45.071542+00:00 app[web.1]:
2024-08-27T18:24:45.071543+00:00 app[web.1]: (ecto 3.11.2) lib/ecto/repo/queryable.ex:157: Ecto.Repo.Queryable.one/3
2024-08-27T18:24:45.071543+00:00 app[web.1]: (slax 0.0.1) lib/slax/github.ex:570: Slax.Github.retrieve_token/1
2024-08-27T18:24:45.071543+00:00 app[web.1]: (slax 0.0.1) lib/slax/github.ex:510: Slax.Github.load_issue/1
2024-08-27T18:24:45.071544+00:00 app[web.1]: (slax 0.0.1) lib/slax_web/websockets/issue.ex:69: SlaxWeb.Issue.load_pr_or_issue_from_github/1
2024-08-27T18:24:45.071545+00:00 app[web.1]: (elixir 1.16.2) lib/enum.ex:1801: anonymous fn/2 in Enum.map_join/3
2024-08-27T18:24:45.071545+00:00 app[web.1]: (elixir 1.16.2) lib/enum.ex:4378: Enum.map_intersperse_list/3
2024-08-27T18:24:45.071545+00:00 app[web.1]: (elixir 1.16.2) lib/enum.ex:1801: Enum.map_join/3
2024-08-27T18:24:45.071546+00:00 app[web.1]: (slax 0.0.1) lib/slax_web/websockets/issue.ex:28: SlaxWeb.Issue.handle_event/1
2024-08-27T18:24:45.071547+00:00 app[web.1]: Last message: {:gun_ws, #PID<0.3918.0>, #Reference<0.453010869.2900885505.64617>, {:text, "{\"envelope_id\":\"4e20966a-b7e9-4859-91ab-cb01b4260f5b\",\"payload\":{\"token\":\"lxInU0whejh6ZPG2MykbSYzt\",\"team_id\":\"T045BEDPN\",\"context_team_id\":\"T045BEDPN\",\"context_enterprise_id\":null,\"api_app_id\":\"A05P1HT741L\",\"event\":{\"user\":\"U07FG01A27M\",\"type\":\"message\",\"ts\":\"1724783018.953359\",\"client_msg_id\":\"7b271456-0ec9-40d7-8e07-0dbaa4661ffa\",\"text\":\"hunitip\\/platform#752\",\"team\":\"T045BEDPN\",\"blocks\":[{\"type\":\"rich_text\",\"block_id\":\"UGQNV\",\"elements\":[{\"type\":\"rich_text_section\",\"elements\":[{\"type\":\"text\",\"text\":\"hunitip\\/platform#752\"}]}]}],\"channel\":\"CDS9RCNE9\",\"event_ts\":\"1724783018.953359\",\"channel_type\":\"channel\"},\"type\":\"event_callback\",\"event_id\":\"Ev07JS103EP4\",\"event_time\":1724783018,\"authorizations\":[{\"enterprise_id\":null,\"team_id\":\"T045BEDPN\",\"user_id\":\"U030GC5DTK9\",\"is_bot\":false,\"is_enterprise_install\":false}],\"is_ext_shared_channel\":false,\"event_context\":\"4-eyJldCI6Im1lc3NhZ2UiLCJ0aWQiOiJUMDQ1QkVEUE4iLCJhaWQiOiJBMDVQMUhUNzQxTCIsImNpZCI6IkNEUzlSQ05FOSJ9\"},\"type\":\"events_api\",\"accepts_response_payload\":false,\"retry_attempt\":2,\"retry_reason\":\"timeout\"}"}}
dweill commented 2 months ago

addressed by #451