Skip to content
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

TypeError argument of type 'NoneType' is not iterable #1120

Closed
b3g00d opened this Issue Mar 8, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@b3g00d
Copy link

b3g00d commented Mar 8, 2018

I using embedded with 3 level depth. Example:
embedded=='{"item_lines": 1, "item_lines.charge": 1, "item_lines.charge.line_usage": 1}'.
But the result was return an exception

lib/python2.7/site-packages/eve/methods/common.py", line 789, in resolve_embedded_documents
    if last_field not in subdocument:
TypeError: argument of type 'NoneType' is not iterable

I tried to bypass like this and result comeout.

        for subdocument in subdocuments(fields_chain[:-1], resource, document):
            if not subdocument:
                continue
            if last_field not in subdocument:
                continue
            if isinstance(subdocument[last_field], list):
                subdocument[last_field] = list(map(getter,
                                                   subdocument[last_field]))
            else:
                subdocument[last_field] = getter(subdocument[last_field])

Current Eve==0.7.6

Notes:
Some item_lines.charge has been soft deleted

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Mar 16, 2018

Some item_lines.charge has been soft deleted

That's probably what triggers the exception. Thanks for reporting. Feel free to submit a fix, I'll gladly review it.

@nicolaiarocci nicolaiarocci added the bug label Mar 16, 2018

@rohanraj7316

This comment has been minimized.

Copy link

rohanraj7316 commented Apr 29, 2018

Hi,
can I take this issue?

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented May 3, 2018

Of course.

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented May 25, 2018

@rohanraj7316 are you still on this?

@rohanraj7316

This comment has been minimized.

Copy link

rohanraj7316 commented May 26, 2018

@jlismore

This comment has been minimized.

Copy link

jlismore commented Jun 1, 2018

For anyone with this issue, the below code resolved it for us

for subdocument in subdocuments(fields_chain[:-1], resource, document):
            if not subdocument or last_field not in subdocument:
                continue
            subdocument[last_field] = getter(subdocument[last_field])
@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Jun 18, 2018

I pushed a new branch. Commit 3937c12 should fix the issue at hand.

@b3g00d and @jlismore, can you please test it and let me know if it solves the problem for you? I am having a hard time coding a test for this scenario 😊

@nicolaiarocci nicolaiarocci added this to the 0.8.1 milestone Jun 25, 2018

@b3g00d

This comment has been minimized.

Copy link
Author

b3g00d commented Jun 29, 2018

Sorry guys, I have no experience about contributing on GitHub, let me follow the issue, and I will test it in a short time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.