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

Improve error debugging with Slack #24

Open
joshua-bn opened this issue Sep 28, 2021 · 7 comments
Open

Improve error debugging with Slack #24

joshua-bn opened this issue Sep 28, 2021 · 7 comments

Comments

@joshua-bn
Copy link

I am having a problem with connecting to Slack. The same issue as #7

I would like to be able to debug this, but there's nothing more that I can see other than there was a 400. It would be great if I got any messages from Slack and any information from the reporter on how to fix that.

@joshua-bn
Copy link
Author

curl -X POST -H 'Content-type: application/json' -H 'Authorization: Bearer ' --data '{"channel":"","blocks":[{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"*Test Summary*"}},{"type":"section","fields":[{"type":"mrkdwn","text":"Total Tests:"},{"type":"mrkdwn","text":"9"},{"type":"mrkdwn","text":"Test Passed:"},{"type":"mrkdwn","text":"9"},{"type":"mrkdwn","text":"Test Failed:"},{"type":"mrkdwn","text":"0"},{"type":"mrkdwn","text":"Test Skipped:"},{"type":"mrkdwn","text":"0"},{"type":"mrkdwn","text":"Test Duration:"},{"type":"mrkdwn","text":"3.7s"},],},{"type":"section","fields":[{"type":"mrkdwn","text":"Assertions:"},{"type":"mrkdwn","text":"Total: 25 Failed: 0"},]},{"type":"divider"},],"attachments":[{"mrkdwn_in":["text"],"color":"#008000","author_name":"Newman Tests","title":":white_check_mark: All Passed :white_check_mark:","footer":"Newman Test","footer_icon":"https://platform.slack-edge.com/img/default_application_icon.png",}] }' https://hooks.slack.com/services/<snipped> this works, but I am still getting the issue with the reporter.

@joshua-bn
Copy link
Author

Hacking away at this. I installed https://www.npmjs.com/package/axios-curlirize and edited slackUtils.js in node_modules so I could test it out. This works. I even tested by removing the duplicate content types there.

curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -H "content-type:application/json" -H "Authorization:Bearer " --data '{"channel":"","blocks":[{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"*Test Summary*"}},{"type":"section","fields":[{"type":"mrkdwn","text":"Total Tests:"},{"type":"mrkdwn","text":"8"},{"type":"mrkdwn","text":"Test Passed:"},{"type":"mrkdwn","text":"8"},{"type":"mrkdwn","text":"Test Failed:"},{"type":"mrkdwn","text":"0"},{"type":"mrkdwn","text":"Test Skipped:"},{"type":"mrkdwn","text":"0"},{"type":"mrkdwn","text":"Test Duration:"},{"type":"mrkdwn","text":"2.9s"},],},{"type":"section","fields":[{"type":"mrkdwn","text":"Assertions:"},{"type":"mrkdwn","text":"Total: 21 Failed: 0"},]},{"type":"divider"},],"attachments":[{"mrkdwn_in":["text"],"color":"#008000","author_name":"Newman Tests","title":":white_check_mark: All Passed :white_check_mark:","footer":"Newman Test","footer_icon":"https://platform.slack-edge.com/img/default_application_icon.png",}] }' "https://hooks.slack.com/services/<snipped>"

@joshua-bn
Copy link
Author

Probably best to just use https://github.com/slackapi/bolt-js

@AdamWillden
Copy link

@jackcoded FYI the transitive dependency axios going from 1.21.1 to 1.21.4 broke our output and started causing 400 errors when talking to slack.

We forced axios back to 0.21.1 and it started working... that was a headache.

Messaging here as perhaps another reason to use another package.

@mehdibenfeguir
Copy link

I'm getting the same problem with slack message reporter
it used to work before now when running
newman run -r slackmsg --reporter-slackmsg-webhookurl my_url --sppress-exit-code

I'm getting
Error in sending message to slack Error: Request failed with status code 400
how can I fix it please ?

@AdamWillden
Copy link

AdamWillden commented Nov 23, 2021

I'm getting the same problem with slack message reporter it used to work before now when running newman run -r slackmsg --reporter-slackmsg-webhookurl my_url --sppress-exit-code

I'm getting Error in sending message to slack Error: Request failed with status code 400 how can I fix it please ?

@mehdibenfeguir, makes sure you’re using --suppress-exit-code as your example has a typo. If your code has the same typo then this would cause 400 errors.

Regarding what I said above, assuming you have the same cause of the 400 error as I did, please uninstall this slackmsg package first then npm install [email protected] with whatever flags you require (-g or --save-dev) then reinstall this package at which point it will use the installed axios version.

Please note it may work with 1.21.2 or 1.21.3 I’ve not tried to find out. I did note that 1.21.1 has a vulnerability but seems unlikely to be an issue here.

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

3 participants