parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

com.parse.ParseRequest$ParseRequestException: invalid key name: 0

Open mghohoo opened this issue 10 years ago • 9 comments

i got a exception as title(on android).it works with parse.com. houseQuery.whereEqualTo("Customer", CloudCustomer.getCurrent()); houseQuery.findInBackground(new FindCallback<CloudHouse>() { @Override public void done(List<CloudHouse> houses, ParseException e) { if (houses==null) e.printStackTrace(); });

mghohoo avatar Jan 30 '16 02:01 mghohoo

Hmm not sure but this feels like an error somewhere in your code. Can you reproduce this in a unit test?

lacker avatar Jan 30 '16 06:01 lacker

@lacker I am also getting the error. I login with Facebook and then try to execute any query and keep on getting this error.

{"code":105,"error":"invalid key name: 0"}

mkpazon avatar Jan 31 '16 01:01 mkpazon

app.js

`express = require('express'); var ParseServer = require('parse-server').ParseServer; var app = express(); // Specify the connection string for your mongodb database // and the location to your Parse cloud code var api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/test', cloud: '', // Provide an absolute path appId: 'myAppId', javascriptKey: 'myJavascriptKey', masterKey: 'mySecretMasterKey', fileKey: 'optionalFileKey', clientKey:'myClientKey' }); // Serve the Parse API on the /parse URL prefix app.use('/', api); // Hello world app.get('/hello', function(req, res) { res.status(200).send('Express is running here.'); }); var port = process.env.PORT || 1337; app.listen(port, function() { console.log('parse-server-example running on port ' + port + '.');

});`

public void test() throws Exception {
    Parse.initialize(
            new Parse.Configuration.Builder(this.getContext())
                    .applicationId("myAppId")
                    .clientKey("myClientKey")
                    .server("http://myhost.com:1337")
                    .enableLocalDataStore()
                    .build());
    ParseQuery<ParseObject>query=ParseQuery.getQuery("Customer");
    query.whereContains("Name","name");
    assertEquals(query.count(), 1);
}

Running tests Test running started com.parse.ParseRequest$ParseRequestException: invalid key name: 0 at com.parse.ParseRequest.newPermanentException(ParseRequest.java:270) at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:301) at com.parse.ParseRequest$3.then(ParseRequest.java:137) at com.parse.ParseRequest$3.then(ParseRequest.java:133) at bolts.Task$15.run(Task.java:917) at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105) at bolts.Task.completeAfterTask(Task.java:908) at bolts.Task.continueWithTask(Task.java:715) at bolts.Task.continueWithTask(Task.java:726) at bolts.Task$13.then(Task.java:818) at bolts.Task$13.then(Task.java:806) at bolts.Task$15.run(Task.java:917) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

mghohoo avatar Jan 31 '16 12:01 mghohoo

The problem seems to be due to JSON handling. The client sends the following JSON in the body {"where":"{\"status\":200,\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"F2ozm6Hgew\"}}","count":"1","_method":"GET"}

but the parse-server returns an error.

Changing the above JSON to the following is successful {"where": {"status":200,"user":{"__type":"Pointer","className":"_User","objectId":"F2ozm6Hgew"}},"count":"1","_method":"GET"}

mkpazon avatar Jan 31 '16 15:01 mkpazon

Reported similar issue observed on the Android-SDK side. https://github.com/ParsePlatform/Parse-SDK-Android/issues/383 . Not sure if this is a client side sdk or parse-server

smanikandan14 avatar Feb 01 '16 01:02 smanikandan14

Merged #105 and hope this is fixed. :+1:

gfosco avatar Feb 01 '16 05:02 gfosco

test passed :+1:

mghohoo avatar Feb 02 '16 09:02 mghohoo

How can I have the parse-server-example package that fixed this?

tranhiepvn avatar Mar 17 '16 10:03 tranhiepvn

Hello, I am having the same issue ParseRequestException invlaid key name. Read through this issue and the other issue #105 yet couldn't fix the issue. Am using android sdk version 1.13.1 Please can you help?

SeunMatt avatar Sep 01 '16 17:09 SeunMatt