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

bot crashes when Slack thread pin limit is exceeded #15

Open
RomanBednar opened this issue Oct 17, 2023 · 3 comments
Open

bot crashes when Slack thread pin limit is exceeded #15

RomanBednar opened this issue Oct 17, 2023 · 3 comments

Comments

@RomanBednar
Copy link

RomanBednar commented Oct 17, 2023

There seems to be a Slack limit set which prevents pinning more than 100 threads in a channel (not sure if this is server specific). The bot is pinning every Jira ticket it is set to watch and when it hits this limit it will crash because the exception is not handled now:

Traceback (most recent call last):
  File "/usr/local/bin/triagebot.py", line 523, in wrapper
    return f(config, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/triagebot.py", line 808, in _check_jira
    [issue.post](http://issue.post/)()
  File "/usr/local/bin/triagebot.py", line 369, in post
    self._client.pins_add(channel=self.channel, timestamp=self.ts)
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/client.py", line 4026, in pins_add
    return self.api_call("pins.add", params=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 156, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 187, in _sync_send
    return self._urllib_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 317, in _urllib_api_call
    ).validate()
      ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/slack_response.py", line 199, in validate
    raise e.SlackApiError(message=msg, response=self)
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: [https://www.slack.com/api/pins.add](https://www.slack.com/api/pins.add))
The server responded with: {'ok': False, 'error': 'too_many_pins'}

The bot could log a warning instead and skip pinning until the count is reduced in a channel.

A second part of the issue is recovering from a large amount of pinned messages. Currently any issue tracked by the bot can be untracked with "Resolve" button for each issue/thread posted in the channel. Similarly it can be unpinned one by one manually. It would be helpful to have a new command, similar to refresh-all that would allow mass resolving (and unpinning) issues after they've been assigned (resolve-all?).

@travier
Copy link
Member

travier commented Oct 17, 2023

We've had this one recently and I wonder if we should "just" not pin issues at all. They are always quickly available in the chat anyway so we don't strictly need it.

travier added a commit to travier/triagebot that referenced this issue Oct 17, 2023
There is a limit of 100 pinned threads in Slack and we currently don't
handle that case properly.

See: coreos#15
@RomanBednar
Copy link
Author

I guess we could live without it, the only downside is that for each issue/thread we would have to "click through" into history and hit "Resolve" there - which is slightly less convenient. Also if there's a huge amount of bug reports (with CVEs usually) the need for mass resolve still stands, although this is more of an RFE and not related to this issue.

@travier
Copy link
Member

travier commented Oct 19, 2023

I've merged #16. This does not "fixes" this but works around it.

We'll happily take a PR with the "full" fix 🙂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants