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

Revise maxLength limit #26

Closed
AndrewLeedham opened this issue Dec 13, 2019 · 10 comments · Fixed by #27
Closed

Revise maxLength limit #26

AndrewLeedham opened this issue Dec 13, 2019 · 10 comments · Fixed by #27
Labels

Comments

@AndrewLeedham
Copy link
Contributor

I believe the maxLength limit here: https://github.com/juliuscc/semantic-release-slack-bot/blob/master/lib/success.js#L9 is outdated the docs seem to indicate that messages will be truncated on Slack's end at 40,000 characters.

Perhaps maxLength should be a config option and defaulted to 3000 as to not break things going forward, but allows a user to increase it as they please. Or maybe set it to 40,000 and bump the major version?

@hannesrabo
Copy link
Collaborator

hannesrabo commented Dec 14, 2019

Hi, this is something that has been previously discussed and it seems like the 3000 character limit still holds.

Here is the previous answer: comment

@hannesrabo
Copy link
Collaborator

Have you successfully tried the package with messages longer than 3000 character? I think it might be possible to have longer messages in case the section block is not used.

@AndrewLeedham
Copy link
Contributor Author

Yes I have experimented with very long messages and more character can get through, but not anywhere near 40000. I have a feeling the limit is based on displayed characters not actual characters, e.g. for a link that displays text is shorter than the full label and URL markup. Just a theory but increasing the max limit definitely allowed more characters through in my testing.

@juliuscc
Copy link
Owner

AFAIK the limit for a message is 40000 characters. However, there is a much stricter limit to consider. When using a section, the character limit in the section is only 3000. Have you tried using a section with more than 3000 characters or only a message?

We are considering to allow a much larger character length when the user inputs a template, but if they use a section the limit should be the same.

@AndrewLeedham
Copy link
Contributor Author

Hnmm I am on holiday this week, so I cannot check. But, I was using an attachment text field with more than 3000 characters, and saw more characters on slack with a higher max limit.

@AndrewLeedham
Copy link
Contributor Author

Ok so sending this in a message body to slack:

{
  "attachments": [
		{
			"title": "Length test",
			"text": "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\nLorem ipsum dolor sit amet consectetur, adipisicing elit. Nihil natus voluptates quisquam assumenda doloremque, ducimus iste ullam, ut dolorum eius delectus quibusdam maxime voluptatum a. Tenetur quasi iste vero ipsum!\n\n"
		}
  ]
}

outputs all of the paragraphs in the message which is around 5500 characters:
image

@juliuscc
Copy link
Owner

The original limit is explicitly based on section, which of course is not mandatory in the case of using templates. Do you think it is possible to detect if there is a section in the template and limit that section to ~3000 characters, but otherwise raise the threshold to a much higher limit (~40,000)?

I do also agree that there should be a way to change the limits, but it should be very clear that it is an unsafe action, and having good defaults should be a priority.

Do you think it would be more clear that we do not recommend to change the config if it is called something like UNSAFE_MAX_LENGTH instead of MAX_LENGTH?

@AndrewLeedham
Copy link
Contributor Author

UNSAFE_MAX_LENGTH sounds sensible to me. It seems that the new blocks api has some more stringent guidelines, e.g: the fields array in a section can have a maximum text length of 2000 and only contain 10 items. Should that be sanitised as well?

I was trying to find some-sort of schema, but slack does not seem to provide anything outside of some TypeScript types (which don't include property length). Also their own node webhook API does not do any sanitisation.

I guess there are a few options:

  1. Always cap section text at 3000 characters, and default the UNSAFE_MAX_LIMIT to 3000 also but allow that to be configured for other fields at the users risk.
  2. Have separate options for different types of fields, so the user can increase the section text limit as well as the attachments text etc.
  3. Add exact sanitisation based on the limits specified in the docs, perhaps based on an JSON Schema file that would be easily updatable. Perhaps said schema can be overrode as an option, so the user can update limits as they see fit?

@juliuscc
Copy link
Owner

juliuscc commented Jan 1, 2020

This problem is more complicated than I first thought 😅 Thanks for the extensive explanation!

I think option 3 is the nicest, but it might not be feasible. I would suggest doing option 1 one until a better solution comes. It will give the control and responsibility to the users of the plugin.

juliuscc pushed a commit that referenced this issue Jan 3, 2020
* feat: add maxLength option

* refactor: prefix max length option with unsafe

* docs(readme): update max length option with unsafe

* docs(readme): revert indent

fixes: #26
@juliuscc
Copy link
Owner

juliuscc commented Jan 3, 2020

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

ping-ci pushed a commit to pinginc/semantic-release-slack-bot that referenced this issue Jan 10, 2025
## 1.0.0 (2025-01-10)

### ⚠ BREAKING CHANGES

* **core:** We only support v18+ of Node and v20+ of semantic-release now. semantic-release library introduced a new version v20 which introduces several breaking changes, including but not limited Node v18 as requirement. More information can be found [here](https://github.com/semantic-release/semantic-release/releases/tag/v20.0.0).
* Drops support for Node 10. semantic-release-slack-bot supports Node 14+ from this version.
* Drops support for Node 8. semantic-release-slack-bot supports Node 10+ from this version.

### Features

* add maxLength option ([juliuscc#27](https://github.com/pinginc/semantic-release-slack-bot/issues/27)) e4000b2, closes juliuscc#26
* add onFail and onSuccess template options c075e91
* add option to specify slack app name ([juliuscc#83](https://github.com/pinginc/semantic-release-slack-bot/issues/83)) 89ee876
* add option to specify slack icon ([juliuscc#80](https://github.com/pinginc/semantic-release-slack-bot/issues/80)) 47952b0
* Add packageName as a config option ([juliuscc#34](https://github.com/pinginc/semantic-release-slack-bot/issues/34)) bf323ca
* Add possibility to provide onSuccess function ([juliuscc#53](https://github.com/pinginc/semantic-release-slack-bot/issues/53)) 1cb7fab
* add slackWebhook as configuration option ([juliuscc#17](https://github.com/pinginc/semantic-release-slack-bot/issues/17)) d3df2b4, closes juliuscc#16
* add support for token/channel option ([juliuscc#79](https://github.com/pinginc/semantic-release-slack-bot/issues/79)) aa1eef6, closes juliuscc#73
* Added a new message form that is published upon a build failure. 6f4afc6
* Added a nicer looking web page. 96b73ad
* Added integration with slack d541e59
* Added option to disable notifications 1117583
* allow to have a custom configuration per branches ([juliuscc#63](https://github.com/pinginc/semantic-release-slack-bot/issues/63)) cab5394
* allow to override slack channel when using webhook ([juliuscc#81](https://github.com/pinginc/semantic-release-slack-bot/issues/81)) 83b4699
* allows a custom environment variable name for Slack webhook ([juliuscc#36](https://github.com/pinginc/semantic-release-slack-bot/issues/36)) a8bec27
* **core:** upgrade semantic-release to version v20 ([juliuscc#104](https://github.com/pinginc/semantic-release-slack-bot/issues/104)) 54ee3bd, closes juliuscc#103
* Empty commit to trigger major release 526e3ef
* **Error message:** Improve error message with a good description a5f7a7b
* Finalized notification messages b8ade21
* implement automatic conversion of Release Notes from Markdown to Slack Markdown f7b1955
* Include package name in notification 20e7a62
* **Logger:** Added logger c22afba
* Made button icon better aligned 3b1e420
* Made index page nice f424e7f
* Nicer error message 2e4a1c2
* Nicer slack message 8ef7a68
* **Notifications:** Added text for notification 1084b5e
* OWL-2911: fork project ([#3](#3)) faee31d
* **templating:** Merged changes with new templating system and updated some details 90d01b6, closes #2
* update semantic release version ([juliuscc#85](https://github.com/pinginc/semantic-release-slack-bot/issues/85)) 4a31a5f

### Bug Fixes

* add keyword (but actually force ci to publish) 07b918d
* add protocol to url starting with git@ ([juliuscc#31](https://github.com/pinginc/semantic-release-slack-bot/issues/31)) 8baf727
* Added a favicon 8c806ea
* Added immediate logging of api exceptions 5679b4e, closes juliuscc#19
* Added verifyCondition hook to check for the correct environment variable aa82207, closes #1
* adjust ci f12f7e9
* Avoid truncating in the middle of markdown ([juliuscc#20](https://github.com/pinginc/semantic-release-slack-bot/issues/20)) bc373f9
* bump peer dependency ([juliuscc#38](https://github.com/pinginc/semantic-release-slack-bot/issues/38)) 6103a60
* bumps semantic-release requirement to <19 ([juliuscc#77](https://github.com/pinginc/semantic-release-slack-bot/issues/77)) 8d844ec
* **ci:** Added checkout to deploy 8b7ffd6
* **ci:** Restored cached filed before deploying e106418
* **ci:** test2 f9df42f
* **ci:** Tried fixing a ci config bug 5c1aea9
* **dependencies:** Added missing dependency 93b12f4
* Fix dependencies 7956978
* Fixed how messages are truncated acec2b5, closes juliuscc#19
* Fixed spelling of JSON fb558a1
* **getrepoinfo:** fix for other TLD checking in repo url ([juliuscc#33](https://github.com/pinginc/semantic-release-slack-bot/issues/33)) 22d83db
* make ci work 818fe92
* minor refactor d3e66f2
* npm audit fix 3f1956e
* **package.json:** Made project public 4430fae
* remove hashtag from version number ([juliuscc#94](https://github.com/pinginc/semantic-release-slack-bot/issues/94)) 7795cda, closes juliuscc#93
* rename wrongly named file 7383085
* repo_url typo e30d3a1
* simplify code and add tests ([juliuscc#22](https://github.com/pinginc/semantic-release-slack-bot/issues/22)) cff4304
* slack token missing bearer prefix ([juliuscc#84](https://github.com/pinginc/semantic-release-slack-bot/issues/84)) 1d410f7
* slackToken based message returns a JSON object ([juliuscc#89](https://github.com/pinginc/semantic-release-slack-bot/issues/89)) e85e59c
* **success:** Fixed linting error in success 4e7c7ed
* support more vendors ([juliuscc#25](https://github.com/pinginc/semantic-release-slack-bot/issues/25)) c0c378a
* **template:** fix replacement of a multiple occurence of the same variable ([juliuscc#46](https://github.com/pinginc/semantic-release-slack-bot/issues/46)) 73c2238
* **test:** test1 02af17f
* Truncate release notes on "onSuccessTemplate" ([juliuscc#23](https://github.com/pinginc/semantic-release-slack-bot/issues/23)) ad3b0af, closes juliuscc#21
* truncated release notes > 3000 chars b5a861c
* Update creation of tag link in default success template ([juliuscc#90](https://github.com/pinginc/semantic-release-slack-bot/issues/90)) 9f4c735, closes juliuscc#82
* update peer dependency to allow future semantic release versions ([juliuscc#108](https://github.com/pinginc/semantic-release-slack-bot/issues/108)) 4a89801
* updated green color 7b63086
* upgrade micromatch ([juliuscc#123](https://github.com/pinginc/semantic-release-slack-bot/issues/123)) 34e721a
* use package_name on fail message ([juliuscc#109](https://github.com/pinginc/semantic-release-slack-bot/issues/109)) 214aef0
* Used the linter c4c0f3d
* **verify-conditions:** Added check for non existant package name dc5f1c1, closes #4

### Other

* Add possibility to turn off truncation ([juliuscc#52](https://github.com/pinginc/semantic-release-slack-bot/issues/52)) 32cf994
* Add screenshot e785e3a
* add semantic release 8c20cb5
* Add slack badge 4726b05
* Added a lint stage to the ci 57bf855
* Added colaborator to license 30f6fd5
* Added lambda and redirect page d1089d2
* Added printers with all valid properties b925a19
* Added security related instructions 297f9ca
* Added stuff a7eea92
* Added two better screenshots 9e6208c
* append Template to options 899ba64
* Bump dependencies ([juliuscc#55](https://github.com/pinginc/semantic-release-slack-bot/issues/55)) 3c499f3
* bump slackify-markdown ([juliuscc#69](https://github.com/pinginc/semantic-release-slack-bot/issues/69)) c8cb52b
* Create PRIVACY.md d47e989
* feat(ci): aa6a5f5
* Finalized truncation of too long messages 53b563f
* fix circleci badge link d32447b
* fixed old title dc897d9
* Fixes nicer indentation in code snippets 1b0af6a
* github_path > repo_path + added repo_url 907d2d8
* Initial commit 390f1bb
* Makes code in Readme.md nicer 8e55982
* Merge branch 'AndrewLeedham-master' 329c85a
* Merge branch 'master' of github.com:juliuscc/semantic-release-slack-bot ce4c896
* Merge pull request [juliuscc#11](https://github.com/pinginc/semantic-release-slack-bot/issues/11) from juliuscc/dependabot/npm_and_yarn/lodash.template-4.5.0 83cb943
* Merge pull request [#5](#5) from thopaw/fix-message-length 3c5a70d
* Merge remote-tracking branch 'origin/master' 9f415b3
* **naming:** Rename test files ([juliuscc#54](https://github.com/pinginc/semantic-release-slack-bot/issues/54)) be18847
* npm init 2b6c206
* **prettier:** changes tab indentation to 2 space indentation ([juliuscc#32](https://github.com/pinginc/semantic-release-slack-bot/issues/32)) f1aa538
* **Readme.md:** First draft of readme 49ec79d
* **readme:** add templating options 7efa3e2
* **Readme:** Added build status shield 8f3ba60
* **Readme:** Minor update on readme to make more idiomatic 5d330dc
* **Reamde:** Made docs look nicer cb4e01f
* refactored lambda script 9947f86
* Removed comments 2612c08
* Removed comments 9c98379
* Removed trash 4ed30aa
* Removed unnecessary log line. 37e0df5, closes juliuscc#43
* Rename wiki/index.html to docs/index.html 14db594
* **slackChannel:**  missing # in slackChannel ([juliuscc#100](https://github.com/pinginc/semantic-release-slack-bot/issues/100)) e7d1c4d
* test a6d9916
* Update README.md 41a32e1
* Update README.md 63582af
* Upload screenshot 6946c87
* Uppdated deployment URL 3ffea71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants