Update Mobilize connector URI, fix display of errors, fix auth issue #708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1 - Most importantly, this updates the base URI for the Mobilize connector, which was no longer working. WARNING this changes from HTTP to HTTPS which may cause authentication issues? I don't know. The Mobilize Connector has its own custom requests code and doesn't use APIConnector, which I assume would handle the change fine.
2 - Also fixed an issue where the auth information wasn't getting passed from
request_paginate
torequest
, which lead to auth errors.3 - Also (and this is the original reason I opened this PR):
The Mobilize connector uses the following logic to check for request errors:
if 'error' in r.json():
Unfortunately, for most unsuccessful API calls (including 404 file not found, 401 authentication, etc) no json is returned. Because we try to parse it anyway, the user sees an unreadable JSONDecodeError, like
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
instead of the more helpful error message that requests would otherwise return.This fix uses the helper method provided by requests,
r.raise_for_status()
to surface most errors, before moving on to the lineif 'error' in r.json():
(which may still be helpful in a subset of cases).The better fix here is to rewrite the Mobilize connector to use the APIConnector utility, which was created precisely so we wouldn't have to duplicate this kind of general request logic within each connector, but that's a bigger change I don't have time for right now.