Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Truncate slack block text so it is not rejected by slack API#5121

Merged
mderynck merged 1 commit into
devfrom
mderynck/limit-slack-block-text-length
Oct 3, 2024
Merged

Truncate slack block text so it is not rejected by slack API#5121
mderynck merged 1 commit into
devfrom
mderynck/limit-slack-block-text-length

Conversation

@mderynck
Copy link
Copy Markdown
Contributor

@mderynck mderynck commented Oct 3, 2024

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]

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • 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.

@mderynck mderynck added pr:no public docs Added to a PR that does not require public documentation updates release:patch PR will be added to "Other Changes" section of release notes labels Oct 3, 2024
@mderynck mderynck marked this pull request as ready for review October 3, 2024 17:54
@mderynck mderynck requested a review from a team October 3, 2024 17:54
@mderynck mderynck added this pull request to the merge queue Oct 3, 2024
Merged via the queue into dev with commit 33a0c15 Oct 3, 2024
@mderynck mderynck deleted the mderynck/limit-slack-block-text-length branch October 3, 2024 18:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pr:no public docs Added to a PR that does not require public documentation updates release:patch PR will be added to "Other Changes" section of release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants