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

JSON message format invalid #4

Closed
thopaw opened this issue Jun 17, 2019 · 6 comments
Closed

JSON message format invalid #4

thopaw opened this issue Jun 17, 2019 · 6 comments

Comments

@thopaw
Copy link
Contributor

thopaw commented Jun 17, 2019

When I want to use this plugin I get the following error during the execution of the plugin with debug flag:


[17:28:51] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/gitlab"
[17:28:51] [semantic-release] › ℹ  Start step "success" of plugin "semantic-release-slack-bot"
[17:28:51] [semantic-release] [semantic-release-slack-bot] › ℹ  Sending slack notification on success
[17:28:52] [semantic-release] [semantic-release-slack-bot] › ℹ  JSON message format invalid
[17:28:52] [semantic-release] › ✖  Failed step "success" of plugin "semantic-release-slack-bot"
[17:28:52] [semantic-release] › ℹ  Start step "fail" of plugin "semantic-release-slack-bot"
[17:28:52] [semantic-release] [semantic-release-slack-bot] › ℹ  Sending slack notification on fail
[17:28:52] [semantic-release] › ✔  Completed step "fail" of plugin "semantic-release-slack-bot"
[17:28:52] [semantic-release] › ✖  SLACK CONNECTION FAILED:  
{ AggregateError: 
    SemanticReleaseError
        at fetch.then.then.catch.e (/home/thopaw/git/freeyou/api-paymentmethod/node_modules/semantic-release-slack-bot/lib/postMessage.js:25:10)
        at <anonymous>
    at /home/thopaw/git/freeyou/api-paymentmethod/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) name: 'AggregateError' }

Also the emssage of the failure in slack does not contain the name of the project:

An error occurred while trying to publish the new version of undefined!

On a different project with exactly the same config it is working.
Can it be a problem of the length of the slack message?
This is the first run of semantic release and the release-notes are longer then the release-notes on the other project.

The project contains a releaserc.yml.

branch: master
plugins:
  - '@semantic-release/commit-analyzer'
  - '@semantic-release/release-notes-generator'
  - '@semantic-release/gitlab'
  - - semantic-release-slack-bot
    - notifyOnSuccess: true
      notifyOnFail: true

and these versions are defined within the package.json:

"devDependencies": {
    "@semantic-release/changelog": "^3.0.4",
    "@semantic-release/gitlab": "^3.1.5",
    "semantic-release": "^15.13.16",
    "semantic-release-slack-bot": "^1.0.4",
....
@hannesrabo
Copy link
Collaborator

Regarding the error with missing project name: the plugin reads this field from the npm package name defined in the current context. Maybe your project does not define such a name?

@hannesrabo
Copy link
Collaborator

After looking into this I realized that if you run semantic release outside of npm (such as a global package instead of as npm run <run script for semantic-release> it will create the undefined package name. I added checking for this and the option of defining a custom package name in the environment (see documentation).

@hannesrabo
Copy link
Collaborator

I can't reproduce/understand your problem regarding development. Maybe this is also relate. When running in a debugging environment I launch semantic release like this.

SLACK_WEBHOOK="<my hook>" npm run semantic-release where semantic-release is a npm script that runs semantic-release --no-ci

Please elaborate if this is still a problem.

@thopaw
Copy link
Contributor Author

thopaw commented Jun 17, 2019

yes you are right. I run it with
GL_TOKEN=test SLACK_WEBHOOK=http://test npx semantic-release
The same behaviour is within
npm run release

I tried to build a example to reproduce the error but with the very same config and version it is working.
The only difference is the amount of the release notes :-(

@thopaw
Copy link
Contributor Author

thopaw commented Jun 17, 2019

It definitely has something to do with the release notes posted in the slack message.
When I commented the plugin @semantic-release/release-notes-generator out, the slack notifier is working.

Perhaps you can reproduce it with a git repo with many commits (in my case ~50) in the release notes.

@thopaw
Copy link
Contributor Author

thopaw commented Jun 18, 2019

I now can reproduce it.

The following config for semantic release is used:

With the command I generate 50 commits
for i in $(seq 1 50); do touch "test-$i" && git add "test-$i" && git commit -m "feat: added file test$i"; done

When I then start semantic release
SLACK_WEBHOOK=... npm run release -- --no-ci
the error occurs.

I check the docs and it says that within a block the text property must have a length < 3000.

I created a pull request and would be glad, if you accept it and merge it into master.
#5

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