Comments (9)
In my case, this was caused by Slack having too many channels. Ever since I added the cursor code, I never see this error/problem anymore.
from response.
I just got this as well. This might happen if the response from the Slack API is an error rather than a success (the ts
identifies the message in a way, and no message was created). If you add a print(response)
, or print(response['error'])
above that line then you should be able to see the error. In my case, the error was channel_not_found
, as I had followed the setup instructions and used the #incidents
channel, but not yet actually created the channel. I created the channel, and after restarting response it worked as expected.
from response.
I followed the README's instructions to the letter and I am hitting this error too:
response | File "/app/slack/models/headline_post.py", line 79, in update_in_slack
response | self.message_ts = response['ts']
response | KeyError: 'ts'
Channel exists, and it is public. I added the bot to it too by "@" it. As an extra, "@" ing the bot for help (@incident_bot help) does not do anything. Logs don't show anything either. All URLs udated to use ngrok ones.
As suggested by @danpalmer I added print(response)
to slack/models/headline_post.py
and got the following:
response | {'ok': False, 'error': 'channel_not_found', 'headers': {'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '60', 'Connection': 'keep-alive', 'Date': 'Fri, 14 Jun 2019 12:41:15 GMT', 'Server': 'Apache', 'X-Content-Type-Options': 'nosniff', 'X-Slack-Req-Id': 'xxxxxxxxxxxxxxx', 'X-OAuth-Scopes': 'identify,bot,commands,channels:history,channels:read,users:read,channels:write,chat:write:user,chat:write:bot', 'Expires': 'Mon, 26 Jul 1997 05:00:00 GMT', 'Cache-Control': 'private, no-cache, no-store, must-revalidate', 'Access-Control-Expose-Headers': 'x-slack-req-id', 'X-XSS-Protection': '0', 'X-Accepted-OAuth-Scopes': 'chat:write:bot', 'Vary': 'Accept-Encoding', 'Pragma': 'no-cache', 'Access-Control-Allow-Headers': 'slack-route, x-slack-version-ts', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Referrer-Policy': 'no-referrer', 'Content-Encoding': 'gzip', 'Access-Control-Allow-Origin': '*', 'X-Via': 'haproxy-www-0q2r', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 63d897654686e9908c8e03c9efa9c27c.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'LHR62-C2', 'X-Amz-Cf-Id': 'xxxxxxxxxxxxxxx=='}}
Key is 'error': 'channel_not_found'
. Channel exists. I tried on two different channels even created a new one.
My setup:
- Running locally (development)
- Latest master as of today (14/06/2019)
- My
.env
:
INCIDENT_CHANNEL_NAME="001-incident-tests"
INCIDENT_BOT_NAME="incident_bot"
PAGERDUTY_ENABLED="False"
Any suggestions
EDIT:
as per https://api.slack.com/methods/chat.postMessage :
channel_not_found : Value passed for channel was invalid
from response.
I'm currently having the same issue and in my case it seems to be due to having way too many channels in Slack.
In https://github.com/monzo/response/blob/master/response/settings/dev.py#L53-L56 the code tries to get the Slack channel ID by calling https://github.com/monzo/response/blob/master/response/settings/base.py#L191
My assumption is that this api call does not handle pagination properly, if you have more than 1000 channels in Slack the API call will return you a thousand and a cursor to get the next batch of channels. If get_channel_id doesn't find any channel then response will just set it to None and that pretty much breaks everything.
from response.
This may also happen if you don't have enough permissions. You may need an additional scope. If you see the scope that is needed in slack oAuth permissions you may need to update your SLACK_TOKEN
environment variable with the latest token.
from response.
Any clues on this one?
I get the channel_not_found
error, but:
INCIDENT_CHANNEL_NAME="incidents"
And I have an #incidents channel. We only have maybe a few hundred Slack channels (how would I know?). I'm going to try again now with a channel called 00-incidents
and hopefully that will sort enough to the start (if the problem is too many channels).
UPDATE: Nope. I re-configured everything with INCIDENT_CHANNEL_NAME="00-incidents"
and created the channel, and still get the same error.
from response.
For precision, the error is:
response | Error: channel_not_found, Need: None
Is this a whole different issue than the KeyError: 'ts'
issue that this is attached to? I also get that, but I feel like maybe the ts
KeyError problem is a generic thing you get all the time, and the most common cause right now is the channel_not_found
? Just a guess from reading the Issue, but I might be just hoping since that's my particular situation.
from response.
The above responses are correct - this generally happens because the Slack API returns slightly weird responses - if there's an error, we get a response like this:
{
"ok": false,
"error": "channel_not_found"
}
Previously, the code would only look for the ["ts"]
key, and not find it in this response, causing that error.
We've done some refactoring recently to the Slack client (in #83 ) so that it now explicitly checks any response from the Slack API for {"ok": true}
and raises an exception if that's not present, which should make debugging issues like this much easier 🙏
from response.
We've released 0.1.1 which includes better error handling for Slack - it should be much easier to debug instances of this in future. If there are specific bugs around Slack handling (like the Slack channel cursoring @philovivero mentioned), please raise a new issue and we'll take it from there ❤️
https://github.com/monzo/response/releases/tag/release-0.1.1
from response.
Related Issues (20)
- What is the 'action' command supposed to do? HOT 2
- Improvements in slack integration HOT 4
- Possible to set a channel name that's too long
- Possible to add a notification with a name that's too long
- Items in response/docs/slack_app_config.md are in the wrong order
- [Suggestion] - Try to avoid fault releases? HOT 1
- Rendering Changes to Reporter or Incident Lead
- 'channels.invite': user_not_found when creating new Comms Channel HOT 2
- Error calling Slack API endpoint 'channels.list': method_deprecated HOT 9
- Deeplink to incident Slack channel from the incidents page
- Incident Reports not showing at incident channel HOT 1
- Clarification for INCIDENT_CHANNEL_ID and INCIDENT_REPORT_CHANNEL_ID HOT 3
- Edit incident via GUI
- Rate limiting issues with users_list call HOT 1
- Rancher issues INC3519219 : Unable to logon to SPM , gravity throwing error 500
- Got ModuleNotFoundError: No module named 'after_response'
- Racher Logs to Splunk
- Build to Upgrade bleach to 3.3.0 is failing due to django-incident-response 0.5.1 depends on bleach 3.1.4
- SPM portfolio management services are not loading
- docker-compose build error at step 2/8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from response.