Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

on error in "__init__.BaseAPI()", only the error text is shown, not the error details, unlike Slack's API Tester #157

Open
fixbugsnow opened this issue Sep 28, 2019 · 2 comments

Comments

@fixbugsnow
Copy link

fixbugsnow commented Sep 28, 2019

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

@eedwards-sk
Copy link

How are we supposed to figure out required permissions currently?

Is it just a guessing game?

This seems like an obvious improvement.

@fixbugsnow
Copy link
Author

fixbugsnow commented Oct 30, 2019

agree, thanks. I guess a couple of ways to get around the guessing game are either:

  1. 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,

  1. (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!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants