on error in "__init__.BaseAPI()", only the error text is shown, not the error details, unlike Slack's API Tester
fixbugsnow opened this issue · 2 comments
currently, in "__ init __.BaseAPI()" , on an error, only the error text is shown:
e.g. "slacker.Error: missing_scope"
which hides the detailed reasons for the error, 'coz of usage of just "error.text", instead of using "error.raw", in line # 112
this change has been implemented in these lines in the below forked repo:
https://github.com/fixbugsnow/slacker/blob/master/slacker/__init__.py#L102-L112
making this change will show the full error details, so the users knows all the reasons behind the error, just like Slack's API "Tester" shows the detailed results for errors:
e.g. slacker.Error: '{"ok": false,"error": "missing_scope","needed": "users:read","provided": "admin,identify"}
pgm flow happens (and still will happen) like so:
Traceback (most recent call last):
* * *
File "c:\program files (x86)\python37\lib\site-packages\slacker\__init__.py", line 332, in list
return self.get('users.list', params={'presence': int(presence)})
File "c:\program files (x86)\python37\lib\site-packages\slacker\__init__.py", line 121, in get
api, **kwargs
File "c:\program files (x86)\python37\lib\site-packages\slacker\__init__.py", line 103, in _request
raise Error(response.raw)
slacker.Error: {"ok":false,"error":"missing_scope","needed":"users:read","provided":"admin,identify"}
would like to see this change (or better) implemented in this original repo, for benefit of users of this repo and it's forks
How are we supposed to figure out required permissions currently?
Is it just a guessing game?
This seems like an obvious improvement.
agree, thanks. I guess a couple of ways to get around the guessing game are either:
- to pre-determine all the access caveats (manually or automated) for each Slack object type and store 'em in a JSON/db/file and use it to know which accesses should be used for what object type, perform all these grants (manully or automated) and then we won't have any errors for processing actions like backups, etc.
or,
- (if we don't like the above option) to automate the adds/updates of the permissions in a loop - from the error msg, whose structure is pretty standard (no AI that is, LOL), e.g.:
slacker.Error: '{"ok": false,"error": "missing_scope","needed": "users:read","provided": "admin,identify"}
clearly says what the error is, what's lacking and what's needed. So in the loop we find out the permissions that are lacking and make Slack API calls to add/update them, until there are no errors.
Hope this answers your qn. Will post other options, as and when I can come up with 'em.
Thanks again!!