Skip to content

Conversation

nicmendoza
Copy link

@nicmendoza nicmendoza commented Sep 17, 2024

Per the documentation, the value for the "error" key in the API response to an error will typically be a dictionary , but may sometimes be a string, as shown here in the API documentation: https://airtable.com/developers/web/api/errors#anchor-404

Since this string-only response is not supported in airtable.py currently, this case will raise a somewhat opaque error. An example of the type of issue you will see was reported in issue #60.

This PR adds some branches in the logic to handle both expected cases, as well as a generalized and also a fallback.

@nicmendoza nicmendoza changed the title Update error handling to branch on shape of error Fix: Handle API errors returned as strings Sep 17, 2024
Copy link
Owner

@pcorpet pcorpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for sending a fix.

error_type=error_json.get('type', str(response.status_code)),
message=error_json.get('message', json.dumps(response.json())))
error_json = r.json().get('error', {})
if isinstance(error_json, dict):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation here, please dedent one tab.

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

Successfully merging this pull request may close these issues.

2 participants