Change consent provider backend to graphql
Merge request reports
Activity
Needs to be done after !3 (merged)
added Blocked label
mentioned in issue #11 (closed)
assigned to @arie
mentioned in merge request !5 (merged)
added 15 commits
-
1c9f193c...dcf5237e - 14 commits from branch
master
- 5418ac77 - Merge changes from master
-
1c9f193c...dcf5237e - 14 commits from branch
removed Blocked label
unassigned @mark
assigned to @arie
- Resolved by Mark
- Resolved by Mark
- consent_provider/db.py 0 → 100644
13 self._load_remote_user_info() 14 15 def _load_remote_user_info(self): 16 querystring = '''{{ 17 getUser(username: "{0}"){{ 18 email, 19 applications{{ 20 edges{{ 21 node{{ 22 name 23 }} 24 }} 25 }} 26 }}}}'''.format(self.username).strip() 27 result = loads(GRAPHQL_CLIENT.execute(querystring)) 28 if "data" in result: The graphql library will throw a HTTPError exception
try: response = urllib.request.urlopen(req) return response.read().decode('utf-8') except urllib.error.HTTPError as e: print((e.read())) print('') raise e
https://github.com/prisma-labs/python-graphql-client/blob/master/graphqlclient/client.py
my suggestion would be to catch the error and wirte a logging message that the backend server responded with an error. Im not sure though if the user should be informed that the reason the request was revoked is that there is an internal server error. In that case the exception needs to be raised again and then handled in the app.py, revoking the consent with different message.
Edited by MarkI agree with your suggestion, and I do think that it's useful to re-raise the exception and handle it downstream. It will make debugging so much easier.
Besides that, my actual question was about the missing
else
to thisif
. I assume that something has gone seriously wrong if theif
is not satisfied, so I think it would be good to do something other than silently returning an empty object – for instance, throwing an exception.changed this line in version 8 of the diff
An exception will now be raised in the constructor of the db.user class. I catch it in the
app
and write it to stdout (as long as I didn't take care of propper logging that should be fine i think). Instead of raising it there again, the consent request will be rejected with an "internal server error" message. I thought it would be nicer to redirect the user back to the application of origin displaying an error message that may help the user to understand what is going on.
- Resolved by Mark