-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Labels
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
The Python Connector currently uses raise_for_status=True when using aiohttp's ClientSession.
The default behaviour for this argument is to close http connections when response status code > 400 and raise generic error message (ex. 400 Bad Request), so the response body which may have a more helpful error message or instructions cannot be accessed.
It is recommended to not use raise for status if access to the errors response body is required. Because of this the Python Connector should do something along the following (pseudocode):
def convert_response(resp):
# attempt to read response and format custom error
try:
resp_body = await resp.json()
# ... raise error using standard response format
build_error(resp.status, resp_body)
# if error occurs reading response body, fallback to raise_for_status
except:
resp.raise_for_status()
# --------------------------------------------------------------------
# ... inside _get_metadata (refresh_utils.py)
async with client_session.get(url, headers=headers) as resp:
# if not 2XX status code
if not resp.ok:
# handle standard response and format it into error
convert_response(resp)
# ... continue onwardsMetadata
Metadata
Assignees
Labels
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.