Closed pastorhudson closed 4 years ago
This fixes it:
try:
for key in cur['relationships']:
relationships = cur['relationships'][key]['data']
if relationships is not None:
if isinstance(relationships, dict):
for include in response['included']:
if include['type'] == relationships['type'] and \
include['id'] == relationships['id']:
record['included'].append(include)
elif isinstance(relationships, list):
for relationship in relationships:
for include in response['included']:
if include['type'] == relationship['type'] and \
include['id'] == relationship['id']:
record['included'].append(include)
except KeyError:
pass
I'd do a pull request, but I can't figure out how to test this with your json mock-ups.
Thanks for all your work on this!
🎉Woohoo--nice work! Glad you found this before I published to PyPi. I will make sure this is fixed before 1.0 is published.
The mocks that aren't done manually are all automatically generated by vcr.py.
As long as you've got creds set up in your dev environment as described here, the mocks will auto generate (and NOT store your API keys 🙂).
Thank you!
I'll leave it open so you have a bookmark.
This is fixed in 7a1c1a3b2e7b524bdc7265c7f7ad1167df5fff55.
I decided to fix this by checking for the existence of the relationships key rather than looking for a KeyError
on the whole block. I'm thinking that catching KeyError
on the whole block could cause silent failures in situations where we wouldn't want things to fail silently. For instance, if a dict
key is missing from one of the other places in this block, falsely make the caller think there are no included objects, when there actually are (but they've been hidden because of catching KeyError
).
I started playing with the dev 1.0 code.
I found a bug :bug:
This code raises a
KeyError: 'relationships'
This is an endpoint Planning Center recently added so I could build import export for pcochef and services reports.
Traceback:
If this is known, and I'm just poking your baby before it's ready feel free to close it up.