Skip to content

Requesting an attribute as a relationship crashes servers #56

@Redsandro

Description

@Redsandro

Requesting a recource with an include for a relationship that does not exist but is a known attribute for the resource throws an uncaught error (and crashes certain live websites)

Request:

http://<server>/api/resource/<some-id>/?include=<some-attribute>

Result:

/var/www/test/node_modules/mongodb/lib/utils.js:123
    process.nextTick(function() { throw err; });
                                  ^

TypeError: Cannot read property '__one' of null
    at iterate (/var/www/test/node_modules/jsonapi-server/lib/postProcessing/include.js:63:53)
    at includes.forEach.include (/var/www/test/node_modules/jsonapi-server/lib/postProcessing/include.js:96:5)
    at Array.forEach (<anonymous>)
    at Object.includePP._arrayToTree (/var/www/test/node_modules/jsonapi-server/lib/postProcessing/include.js:95:12)
    at Object.includePP.action [as _applyIncludes] (/var/www/test/node_modules/jsonapi-server/lib/postProcessing/include.js:19:13)
    at async.waterfall.next (/var/www/test/node_modules/jsonapi-server/lib/postProcess.js:17:25)
    at nextTask (/var/www/test/node_modules/async/dist/async.js:5310:14)
    at next (/var/www/test/node_modules/async/dist/async.js:5317:9)
    at /var/www/test/node_modules/async/dist/async.js:958:16
    at Object.filter.action [as _applyFilter] (/var/www/test/node_modules/jsonapi-server/lib/postProcessing/filter.js:12:24)
[nodemon] app crashed - waiting for file changes before starting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions