You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However this test will never actually return this detail message because when this check happens:
data_keys = set(map((
lambda x: resource.__jsonapi_map_to_py__.get(x, None)),
data['data'].get('relationships', {}).keys()))
model_keys = set(resource.__mapper__.relationships.keys())
if not data_keys <= model_keys:
raise BadRequestError(
'{} not relationships for {}'.format(
', '.join(list(data_keys -
model_keys)), model.__jsonapi_type__))
When we take the difference between data_keys and model_keys we are getting {None} because data_keys = {'posts',None'} and model_keys = {'posts','comments',logs'}.
When the BadRequestError is raised we get a TypeError: sequence 0: expected str instance, NoneType found.
This happens on both python3 and python2.
I will look at more as to how to fix this.
The text was updated successfully, but these errors were encountered:
This same TypeError: sequence 0: expected str instance, NoneType found also occurs in patch_resource when trying to raise a BadRequestError. Will put up issue.
kaitj91
changed the title
TypeError occurs when formatting detail when raising BadRequestError with garbage relationships
TypeError occurs when formatting detail when raising BadRequestError with garbage relationships in post_collection
Mar 22, 2017
Yes. Basically if you look at the test I posted above, we are trying to make sure we flag relationships that are not existent and raise a BadRequestError for those. So someone could send garbage input for the relationship keys, as I did in that test with dogs, and we would give a meaningful error message back so they understand the relationship between 'dogs' and 'users' does not exist. In other words, we are checking if data_keys is a subset of model_keys.
Here is a test that should return a BadRequestError:
However this test will never actually return this detail message because when this check happens:
When we take the difference between data_keys and model_keys we are getting
{None}
becausedata_keys = {'posts',None'}
andmodel_keys = {'posts','comments',logs'}
.When the BadRequestError is raised we get a
TypeError: sequence 0: expected str instance, NoneType found.
This happens on both python3 and python2.
I will look at more as to how to fix this.
The text was updated successfully, but these errors were encountered: