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

Error raised when using embedded with nested dict. #1416

Closed
pramos12 opened this issue Oct 20, 2020 · 0 comments
Closed

Error raised when using embedded with nested dict. #1416

pramos12 opened this issue Oct 20, 2020 · 0 comments

Comments

@pramos12
Copy link
Contributor

Expected Behavior

Using following schemas:

brands = {
    "item_title": "brand",
    "schema": {
        "name": {"type": "string"},
        "address": "string",
    }
}

components = {
    "item_title": "component",
    "schema": {
        "name": {"type": "string"},
        "price": "integer",
        "brand": {"type": "objectid", "data_relation": {"resource": "brands"}},
    }
}

computers = {
    "item_title": "computers",
    "schema": {
        "name": {"type": "string"},
        "components": {
            "type": "dict",
            "schema": {
                "cpu": {"type": "objectid", "data_relation": {"resource": "components"}},
                "motherboard": {"type": "objectid", "data_relation": {"resource": "components"}},
            }
        }
    }
}

Making the following request:

/computers/5f8e82e3b51714d566994c13?embedded={"components.cpu": 1, "components.motherboard": 1, "components.cpu.brand": 1, "components.motherboard.brand": 1} [GET]

Should provide results with embedded documents

Actual Behavior

Error is raised:

-------------------------------------------------- Captured log call --------------------------------------------------
ERROR    eve:app.py:1891 Exception on /computers/5f8e82e3b51714d566994c13/ [GET]
Traceback (most recent call last):
  File "c:\dev\github\eve\env\lib\site-packages\flask\app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "c:\dev\github\eve\env\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "c:\dev\github\eve\env\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "c:\dev\github\eve\env\lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "c:\dev\github\eve\env\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "c:\dev\github\eve\env\lib\site-packages\flask\app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\dev\github\eve\eve\endpoints.py", line 94, in item_endpoint
    response = getitem(resource, **lookup)
  File "C:\dev\github\eve\eve\methods\common.py", line 325, in rate_limited
    return f(*args, **kwargs)
  File "C:\dev\github\eve\eve\auth.py", line 80, in decorated
    return f(*args, **kwargs)
  File "C:\dev\github\eve\eve\methods\common.py", line 1369, in decorated
    r = f(resource, **combined_args)
  File "C:\dev\github\eve\eve\methods\get.py", line 321, in getitem
    return getitem_internal(resource, **lookup)
  File "C:\dev\github\eve\eve\methods\get.py", line 414, in getitem_internal
    build_response_document(document, resource, embedded_fields, latest_doc)
  File "C:\dev\github\eve\eve\methods\common.py", line 673, in build_response_document
    resolve_embedded_documents(document, resource, embedded_fields)
  File "C:\dev\github\eve\eve\methods\common.py", line 1110, in resolve_embedded_documents
    for subdocument in subdocuments(fields_chain[:-1], resource, document):
  File "C:\dev\github\eve\eve\methods\common.py", line 1066, in subdocuments
    for result in subdocuments(fields_chain[1:], resource, doc):
  File "C:\dev\github\eve\eve\methods\common.py", line 1059, in subdocuments
    resource = field_definition(resource, fields_chain[0])["data_relation"][
TypeError: 'NoneType' object is not subscriptable

Environment

  • Python version: 3.8.x
  • Eve version: 1.1.3
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

No branches or pull requests

1 participant