Skip to content

server crash on query of nonexistent field relation #280

Closed
@lucianmat

Description

@lucianmat

Sending query for a relationship that has not yet registered field, it will crash the server :

Promise.resolve()
    .then(()=>{
        var object = new Parse.Object('TestObject');
        object.set('name','Named');
        return object.save()
            .then(function (rez) {
                var query =rez.relation('users').query();
                return query.find()
                        .then((users)=>{
                            console.log(users);
                        },(err)=>{
                            console.error(err);
                        });
            });
    })

It will crash with error :

Uncaught internal server error. [TypeError: Cannot read property 'match' of undefined] TypeError: Cannot read property 'match' of undefined
    at [...]/parse-server/ExportAdapter.js:108:18
    at process._tickDomainCallback (node.js:444:9)

To fix, I think that line 108 should be :

var match = t ? t.match(/^relation<(.*)>$/) : false;

(as it is in similar function reduceInRelation )

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