-
Notifications
You must be signed in to change notification settings - Fork 47
TDL-16827 'str' object has no attribute 'get' #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TDL-16827 'str' object has no attribute 'get' #59
Conversation
KrisPersonal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When making any change to the code please comment the code. Why the code is changed and what was changed?
tap_google_sheets/client.py
Outdated
| # There is nothing we can do here since Google has neither sent | ||
| # us a 2xx response nor a response content. | ||
| return | ||
| status_code = response.status_code # Get status code of the response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous, it was trying to get status code from error.code of JSON response. But in many responses, the value of the error key is just a string. So, it was throwing AttributeError: 'str' object has no attribute 'get' because of error.code missing in response. So, here we are retrieving the status code from the response object itself.
| response.get('message', 'Unknown Error')) | ||
| error_code = response.get('error', {}).get('code') | ||
| ex = get_exception_for_error_code(error_code) | ||
| message = 'HTTP-error-code: %s %s: %s' % (status_code, response.get('error', str(error)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous, if 'message' does not found in JSON response then it was showing directly Unknown Error in the error message. But, we observed that in many responses error_description comes as a detailed cause of the error. So, here we added an extra check for error_description to better readability. If error_description also does not found then it shows Unknown Error.
Description of change
response.status_codeattribute.error_descriptionin an error message if available in response.Manual QA steps
Risks
Rollback steps