oncall-engine/engine/apps/slack
Michael Derynck 33a0c15b75
Truncate slack block text so it is not rejected by slack API (#5121)
# What this PR does
Truncates text for slack message to avoid this error:
```
File "/usr/local/lib/python3.12/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/chat.postMessage)
The server responded with: {'ok': False, 'error': 'invalid_blocks', 'errors': ['failed to match all allowed schemas [json-pointer:/blocks/0/text]', 'must be less than 3001 characters [json-pointer:/blocks/0/text/text]'], 'response_metadata': {'messages': ['[ERROR] failed to match all allowed schemas [json-pointer:/blocks/0/text]', '[ERROR] must be less than 3001 characters [json-pointer:/blocks/0/text/text]']}}
```

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-10-03 18:45:23 +00:00
..
migrations Unified Slack app reinstall (#4682) 2024-07-19 11:53:06 +00:00
models Truncate slack block text so it is not rejected by slack API (#5121) 2024-10-03 18:45:23 +00:00
representatives remove leftofter/deprecated slack log report tasks (#4858) 2024-08-19 19:10:46 -04:00
scenarios Handle Slack invalid_auth error when posting alert group notification (#4970) 2024-09-02 16:37:27 +00:00
tests Update schedule related users to use cached final representation (#5101) 2024-10-01 13:37:28 +00:00
types Introduce slash command matcher (#4717) 2024-07-24 09:53:06 +00:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
alert_group_slack_service.py Do not retry on SlackAPICantUpdateMessageError errors (#4405) 2024-05-28 17:46:15 +00:00
chatops_proxy_routing.py Prepare OnCall for Unified Slack App (#4232) 2024-06-03 09:07:10 +00:00
client.py Update when slack client ratelimit retry handler is enabled (#3447) 2023-11-30 12:35:46 +00:00
constants.py Truncate resolution note text in slack message to satisfy block limits (#3351) 2023-11-16 13:15:04 +00:00
errors.py Update Slack user group for a schedule - handle paid_team_only Slack API error (#4793) 2024-08-09 14:51:01 +00:00
installation.py Unified Slack app reinstall (#4682) 2024-07-19 11:53:06 +00:00
slack_formatter.py Fix alert group rendering (#3424) 2023-11-24 15:39:37 +00:00
slash_command.py Make root command configurable (#4863) 2024-08-21 06:54:47 +00:00
tasks.py remove leftofter/deprecated slack log report tasks (#4858) 2024-08-19 19:10:46 -04:00
test_slack_message.py Don't send request for permalink if slack token has been revoked (#4777) 2024-08-06 15:34:08 +00:00
urls.py Make Slack URLs work without trailing slashes (#4607) 2024-07-03 15:55:54 +00:00
utils.py Address deprecation warnings in tests (#4681) 2024-08-13 20:51:18 +00:00
views.py Make Slack connection error more descriptive (#5007) 2024-09-10 16:24:09 +00:00