Unknown query error?

39 views
Skip to first unread message

Kevin Burton

unread,
Jan 4, 2016, 9:15:26 AM1/4/16
to Node-Neo4j
I am executing a simple query to create a node:

db.query("CREATE (n:AutoFileRuleGroup {props}) RETURN n", params, function (err, result) {
if (err) {
return reject(err);
} else {
return resolve(result);
}
});

But I get an error

"C:\Program Files (x86)\JetBrains\WebStorm 11.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=60374 --nolazy CreateGraphNodes.js
Debugger listening on port 60374
{ [Error: [object Object]]
  stack: [Getter/Setter],
  message: { errors: [ [Object] ] },
  __frame: 
   { name: 'GraphDatabase_prototype_query__20',
     line: 710,
     file: 'lib/GraphDatabase._coffee',
     prev: undefined,
     calls: 1,
     active: false,
     offset: 2,
     col: 24 },
  rawStack: [Getter] }

I cannot see what is the cause of the error. Ideas?


winniehell

unread,
Jan 4, 2016, 3:58:36 PM1/4/16
to node-...@googlegroups.com
Hi Kevin!

> CREATE (n:AutoFileRuleGroup {props}) RETURN n
Is that the exact query you are running? This is not a valid cypher
query - node properties must be key-value-pairs.

Debugging cypher queries is usually easier using the neo4j console:
http://console.neo4j.org/r/7m8j2i

Winnie

signature.asc

Michael Hunger

unread,
Jan 4, 2016, 5:46:20 PM1/4/16
to winniehell, node-...@googlegroups.com
Actually Winnie, it is valid.

Kevin, do you pass a "props" key to a js-object in your params?

I think if you use JSON.stringify on your error you should see the details in "error" field.

Michael

Kevin Burton

unread,
Jan 4, 2016, 6:50:57 PM1/4/16
to Node-Neo4j
This is the query but the key-value pairs are in props that is passed in as an argument.

Michael Hunger

unread,
Jan 4, 2016, 6:52:26 PM1/4/16
to Kevin Burton, Node-Neo4j
Then you have one level that provides the "props" key:

db.query("CREATE (n:AutoFileRuleGroup {props}) RETURN n", {props: params}, function (err, result) {

if (err) {
return reject(err);
} else {
return resolve(result);
}
});

Kevin Burton

unread,
Jan 4, 2016, 6:55:26 PM1/4/16
to Node-Neo4j, g...@winniehell.de
I am passing "props" as a JSON object. To show you a little more code this is what I am working with:

var props = {};
for (var property in row) {
if (row.hasOwnProperty(property)) {
props[property] = row[property];
}
}
props['id'] = row.autoFillRuleID;
var params = {
props: props
};
return new Promise(function(resolve, reject) {
db.query("CREATE (n:AutoFileRule {props}) RETURN n", params, function(err, result) {

if(err) {
return reject(err);
} else {
return resolve(result);
}
});
});


Just to be clear the err passed back is JSON it needs to be stringified?

Michael Hunger

unread,
Jan 4, 2016, 7:20:02 PM1/4/16
to Kevin Burton, Node-Neo4j, g...@winniehell.de
Looks good to me.

Do you have the connection / URL / auth set up correctly?

Do reads work?

What I meant is that in your error output you don't see the details because the nested objects are not rendered to the output.

Kevin Burton

unread,
Jan 4, 2016, 10:03:17 PM1/4/16
to Michael Hunger, Node-Neo4j, g...@winniehell.de
The connection URL is set to localhost:7474 just as it suggests during installation. I haven't tried reads because the database is empty. But I suppose I could put in some dummy data just to give some more information.
I am setting a breakpoint in the callback so I can see the error (all be it inconclusive) with the debugger.

Aseem Kishore

unread,
Jan 5, 2016, 5:12:50 AM1/5/16
to Kevin Burton, Michael Hunger, Node-Neo4j, g...@winniehell.de
Thanks for chiming in, everyone!

I've been out of commission as I'm recently engaged now =), so wedding planning has been in full force...

Kevin, I agree your code looks fine to me. It looks like the main issue is just that you're not able to see what the error actually is, as you mention. I assume you're `console.log`'ing the error somewhere. Node pre-0.12 (or is it pre-v4?) doesn't log errors in a very friendly/readable way, but still, `message` should be a string.

For now, what happens if you `JSON.stringify(err.message)`? Or console.log `err.stack` specifically?

Btw, it looks like you're using node-neo4j v1 (based on `db.query`) . Just FYI that node-neo4j v2 dramatically improves error reporting:


Hope this helps, and good luck! =)


Kevin Burton

unread,
Jan 5, 2016, 7:58:39 AM1/5/16
to Aseem Kishore, Michael Hunger, Node-Neo4j, g...@winniehell.de
Thank you. I created nodes and relationships from the "getting started" tutorial so it doesn't seem to be the installation, configuration, or setup of neo4j itself.

You are right I am using 1.1.1 but that just came when I installed (about a month ago). Forgive me but I am not sure how to bump the version of node-neo4j.

Kevin Burton

unread,
Jan 5, 2016, 8:19:13 AM1/5/16
to Node-Neo4j, aseem....@gmail.com, michael...@neotechnology.com, g...@winniehell.de
I may have posted twice but I cannot find my latest post here.

I upgraded to node-neo4j 2.0 RC2. Now I get an error db.query is not a function. I tried looking at the API documentation but it seems some server is down. Is it relatively easy to convert from db.query passing parameters to the new syntax? Are there still callbacks like before?

Thank you.


Kevin Burton

unread,
Jan 5, 2016, 12:38:38 PM1/5/16
to Node-Neo4j, aseem....@gmail.com, michael...@neotechnology.com, g...@winniehell.de
Thanks again for your support. I was able to get v2 RC2 running. My query now looks like:

db.cypher({ query: "CREATE (n:AutoFileRuleGroup {props}) RETURN n",
params: params },

function (err, result) {
if (err) {
            return reject(err);
} else {
return resolve(result);
}
});


But I am getting an error [Neo.ClientError.Security.AuthorizationFailed] No authorization header supplied.. I am not sure where to put authorization header or how to specify "no authorization"
.
The sample:

db.cypher({
    query
: 'MATCH (u:User {email: {email}}) RETURN u',
   
params: {
        email
: 'al...@example.com',
   
},
}, function (err, results) {
   
if (err) throw err;
   
var result = results[0];
   
if (!result) {
        console
.log('No user found.');
   
} else {
       
var user = result['u'];
        console
.log(JSON.stringify(user, null, 4));
   
}
});


Yields e.g.:

json
{
   
"_id": 12345678,
   
"labels": [
       
"User",
       
"Admin"
   
],
   
"properties": {
       
"name": "Alice Smith",
       
"email": "al...@example.com",
       
"emailVerified": true,
       
"passwordHash": "..."
   
}
}



doesn't seem to have an authorization header. This must be a change.

Thanks again.

Aseem Kishore

unread,
Jan 5, 2016, 12:55:11 PM1/5/16
to Kevin Burton, Node-Neo4j, michael...@neotechnology.com, g...@winniehell.de
Hey Kevin,

Thanks for working through this. =)

Which version of Neo4j are you running? That error message suggests you're running Neo4j 2.2+, which does require auth. (So you can't say "no authorization".)

You have two options: either configure Neo4j to disable auth...


...or pass your username and password either in the URL...

var db = new neo4j.GraphDatabase({url: 'http://neo4j:neo4j@localhost:7474'})

...or as a separate option:

var db = new neo4j.GraphDatabase({url: 'http://localhost:7474', auth: {username: 'neo4j', password: 'neo4j'})

Manual if you haven't come across this yet:


Hope this helps!

Aseem


Michael Hunger

unread,
Jan 5, 2016, 12:57:46 PM1/5/16
to Kevin Burton, Node-Neo4j
Correct.

Kevin - But you are required to change the initial password via the UI or an http request. 
Otherwise it will refuse to accept it.

Kevin Burton

unread,
Jan 5, 2016, 1:46:06 PM1/5/16
to Node-Neo4j, ronald.ke...@gmail.com, michael...@neotechnology.com, g...@winniehell.de
I am sorry but where do I put the line:

# Disable authorization
dbms.security.auth_enabled=false

Aseem Kishore

unread,
Jan 5, 2016, 1:53:35 PM1/5/16
to Kevin Burton, Node-Neo4j, michael...@neotechnology.com, g...@winniehell.de
Inside your Neo4j installation's conf/neo4j-server.properties file.

Kevin Burton

unread,
Jan 5, 2016, 2:00:23 PM1/5/16
to Node-Neo4j, ronald.ke...@gmail.com, michael...@neotechnology.com, g...@winniehell.de

When I disable authentication I get:

[Neo.DatabaseError.Statement.ExecutionFailure] scala.MatchError: (customConfiguration,null) (of class scala.Tuple2)
        at org.neo4j.cypher.internal.compiler.v2_3.mutation.CreateNode$$anonfun$org$$$$7464cf489ed8288ba3ab414a08da84a$$$$e$$fromAnyToLiteral$1$1.apply(CreateNode.scala:48)
        at org.neo4j.cypher.internal.compiler.v2_3.mutation.CreateNode$$anonfun$org$$$$7464cf489ed8288ba3ab414a08da84a$$$$e$$fromAnyToLiteral$1$1.apply(CreateNode.scala:48)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
        at scala.collection.Iterator$class.foreach(Iterator.scala:742)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at org.neo4j.cypher.internal.compiler.v2_3.mutation.CreateNode.org$neo4j$cypher$internal$compiler$v2_3$mutation$CreateNode$$fromAnyToLiteral$1(CreateNode.scala:48)
        at org.neo4j.cypher.internal.compiler.v2_3.mutation.CreateNode$$anonfun$exec$1.apply(CreateNode.scala:85)
        at org.neo4j.cypher.internal.compiler.v2_3.mutation.CreateNode$$anonfun$exec$1.apply(CreateNode.scala:81)
        at scala.collection.Iterator$$anon$11.next(Iterator.scala:370)
        at scala.collection.Iterator$$anon$12.next(Iterator.scala:397)
        at scala.collection.Iterator$$anon$12.next(Iterator.scala:397)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:75)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:72)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator$$anonfun$failIfThrows$1.apply(ResultIterator.scala:121)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.decoratedCypherException(ResultIterator.scala:130)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.failIfThrows(ResultIterator.scala:119)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.next(ResultIterator.scala:72)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.next(ResultIterator.scala:50)
        at scala.collection.Iterator$class.foreach(Iterator.scala:742)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.foreach(ResultIterator.scala:50)
        at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
        at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:183)
        at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)
        at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:308)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.to(ResultIterator.scala:50)
        at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:292)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.toList(ResultIterator.scala:50)
        at org.neo4j.cypher.internal.compiler.v2_3.EagerResultIterator.<init>(ResultIterator.scala:36)
        at org.neo4j.cypher.internal.compiler.v2_3.ClosingIterator.toEager(ResultIterator.scala:56)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.DefaultExecutionResultBuilderFactory$ExecutionWorkflowBuilder.buildResultIterator(DefaultExecutionResultBuilderFactory.scala:104)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.DefaultExecutionResultBuilderFactory$ExecutionWorkflowBuilder.createResults(DefaultExecutionResultBuilderFactory.scala:94)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.DefaultExecutionResultBuilderFactory$ExecutionWorkflowBuilder.build(DefaultExecutionResultBuilderFactory.scala:63)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:230)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:214)
        at org.neo4j.cypher.internal.compiler.v2_3.executionplan.ExecutionPlanBuilder$$anon$3.run(ExecutionPlanBuilder.scala:172)
        at org.neo4j.cypher.internal.compatibility.CompatibilityFor2_3$ExecutionPlanWrapper$$anonfun$run$1.apply(CompatibilityFor2_3.scala:192)
        at org.neo4j.cypher.internal.compatibility.CompatibilityFor2_3$ExecutionPlanWrapper$$anonfun$run$1.apply(CompatibilityFor2_3.scala:192)
        at org.neo4j.cypher.internal.compatibility.exceptionHandlerFor2_3$.runSafely(CompatibilityFor2_3.scala:114)
        at org.neo4j.cypher.internal.compatibility.CompatibilityFor2_3$ExecutionPlanWrapper.run(CompatibilityFor2_3.scala:191)
        at org.neo4j.cypher.internal.PreparedPlanExecution.execute(PreparedPlanExecution.scala:27)
        at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:118)
        at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:112)
        at org.neo4j.cypher.javacompat.internal.ServerExecutionEngine.executeQuery(ServerExecutionEngine.java:62)
        at org.neo4j.server.rest.transactional.TransactionHandle.executeStatements(TransactionHandle.java:328)
        at org.neo4j.server.rest.transactional.TransactionHandle.commit(TransactionHandle.java:147)
        at org.neo4j.server.rest.web.TransactionalService$2.write(TransactionalService.java:211)
        at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:71)
        at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:57)
        at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:302)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
        at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
        at org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:497)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540)
        at java.lang.Thread.run(Unknown Source)
    
from the cypher query

Aseem Kishore

unread,
Jan 5, 2016, 2:06:04 PM1/5/16
to Kevin Burton, Node-Neo4j, michael...@neotechnology.com, g...@winniehell.de
I think I've seen that error (and I've filed a bug) when one of your properties is set to null. Try removing that null property instead of providing it as null?

Kevin Burton

unread,
Jan 5, 2016, 3:49:00 PM1/5/16
to Node-Neo4j, ronald.ke...@gmail.com, michael...@neotechnology.com, g...@winniehell.de
For Windows there is not conf folder I found neo4j.properties in the root folder of the database folder. In my case that was default.graphdb.

Kevin Burton

unread,
Jan 5, 2016, 3:52:56 PM1/5/16
to Node-Neo4j, ronald.ke...@gmail.com, michael...@neotechnology.com, g...@winniehell.de
Thank you that worked!! I filtered out the null properties and it worked. Naturally I would like to at least have a placeholder if the property value is null but this is a good workaround. Thank you.

Aseem Kishore

unread,
Jan 5, 2016, 4:25:05 PM1/5/16
to Kevin Burton, Node-Neo4j, michael...@neotechnology.com, g...@winniehell.de
That's great to hear.

I agree the null issue would be nice to fix; the issue I chimed in on for that is here:


But glad you're unblocked for now.

Aseem


swetha

unread,
Mar 7, 2024, 2:29:25 AM3/7/24
to Node-Neo4j

Flutter training with Brolly Academy covers all aspects of Flutter development, including widgets, layout and navigation, animation and graphics, network programming, and state management.

<a href="https://brollyacademy.com/flutter-training-in-hyderabad/">Flutter Training in Hyderabad</a>
Reply all
Reply to author
Forward
0 new messages