etsy / 411

An Alert Management Web Application
https://demo.fouroneone.io
MIT License
969 stars 112 forks source link

Slack webhook fails with 411 username #30

Closed kasperbrandenburg closed 7 years ago

kasperbrandenburg commented 7 years ago

in Slack.php:62 the CURL 'username' => Util::getSiteName(), attribute seems to cause problems. I created a standard webhook to a slack-channel, and got a 400 Bad request back. I Changed it to "webhookbot" and it startet to work.

kiwiz commented 7 years ago

I tested this out with a numeric sitename and it appears to work fine. Do you have more details?

kasperbrandenburg commented 7 years ago

Writing 411 as text direct in the curl-post() method also works. Its only when the attribute is populated. I tried to grab the actual output by doing print_r($curl); This is some of the data i got back

Error: Uncaught TypeError: Cannot use 'in' operator to search for 'success' in Curl\Curl Object ( [curl]=>Resourceid#15[id]=>1[error]=>1[errorCode]=>400[errorMessage]=>HTTP/1.1400BadRequest[curlError]=>[curlErrorCode]=>0[curlErrorMessage]=>[httpError]=>1[httpStatusCode]=>400[httpErrorMessage]=>HTTP/1.1400BadRequest[baseUrl]=>https: //hooks.slack.com/services/ [url]=>https: //hooks.slack.com/services/ [requestHeaders]=>Curl\CaseInsensitiveArrayObject([data: Curl\CaseInsensitiveArray: private]=>Array([request-line]=>POST/services/ HTTP/1.1[host]=>hooks.slack.com[user-agent]=>PHP-Curl-Class/4.13.0(+https: //github.com/php-curl-class/php-curl-class)PHP/7.0.8-0ubuntu0.16.04.2curl/7.47.0[accept]=>/[content-type]=>application/json;charset=utf-8[content-length]=>329)[keys: Curl\CaseInsensitiveArray: private]=>Array([request-line]=>Request-Line[host]=>Host[user-agent]=>User-Agent[accept]=>Accept[content-type]=>Content-Type[content-length]=>Content-Length))[responseHeaders]=>Curl\CaseInsensitiveArrayObject([data: Curl\CaseInsensitiveArray: private]=>Array([status-line]=>HTTP/1.1400BadRequest[content-type]=>text/html[content-length]=>14[connection]=>keep-alive[access-control-allow-origin]=>*[content-security-policy]=>referrerno-referrer;[date]=>Wed,

kiwiz commented 7 years ago

Hmm, can you try dumping the POST data being passed to Slack. My guess is that getSiteName() is returning null (though that shouldn't happen).

kiwiz commented 7 years ago

@kasperbrandenburg is this still occurring?