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

server crash on query of nonexistent field relation #280

Closed
lucianmat opened this issue Feb 6, 2016 · 4 comments
Closed

server crash on query of nonexistent field relation #280

lucianmat opened this issue Feb 6, 2016 · 4 comments

Comments

@lucianmat
Copy link

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 )

@lucianmat lucianmat changed the title server crash on query of nonexistent field server crash on query of nonexistent field relation Feb 6, 2016
@gfosco
Copy link
Contributor

gfosco commented Feb 7, 2016

Interested in submitting a PR with a test case or two?

@lucianmat
Copy link
Author

Sure.
Added test case as have discovered, as query for Role users before adding any user to role.

@derickito
Copy link

Not sure if this is the correct place to mention this or if I should create a new issue, but after getting this server crash I realized that there's no way to create a relation in the parse-server at least not one that's obvious to me. The docs all mention creating the relation in the data browser, but there is no data browser in the parse server any more. Suggestions?

@gfosco
Copy link
Contributor

gfosco commented Mar 6, 2016

I submitted PR #861 to address this. 👍

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

4 participants