cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Confusing cypher error

Hi all, I am getting a cypher error that I just cannot figure the problem with. I am using docker and neo4j 4.2.2. After spinning up the container I have a cypher script that needs to be run to seed some initial data (this I have done with tremendous help from Dominic Kumar in another thread).

The strange part about this error is that it did appear to work fine but now gives this starnge error.

Here is the detail, I am using this dockerfile

FROM neo4j:4.2.2

ENV NEO4J_HOME="/var/lib/neo4j"

ENV NEO4J_PASSWD=neo4j_dependency

ENV NEO4J_apoc_import_file_enabled=true

ENV APOC_VERSION=4.2.0.1

# SHould look at copying this from a shared resource folder

ADD https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/${APOC_VERSION}/apoc-${APOC_VERSION}-all.jar ${NEO4J_HOME}/plugins

# Copy over generated dependency graph json file from shared resource folder

COPY Dependencies_Tree_Full_UnSorted.json ${NEO4J_HOME}/import/

# copy over cypher script from shared resource folder

COPY data_loader.cypher ${NEO4J_HOME}/import/

# set initial-password to start loading the data

# sleep for 20 secs for neo4j to start without any overlapping

CMD bin/neo4j-admin set-initial-password ${NEO4J_PASSWD} && \

    bin/neo4j start && sleep 20 && \

    if [ -f "${NEO4J_HOME}/import/data_loader.cypher" ]; then  \

        echo "We should be executing the cypher now?" && \

        cat ${NEO4J_HOME}/import/data_loader.cypher | NEO4J_USERNAME=neo4j NEO4J_PASSWORD=${NEO4J_PASSWD} bin/cypher-shell --fail-fast && rm ${NEO4J_HOME}/import/*; \

    fi && tail -f /logs/neo4j.log

and in the dockerfile I execute the following cypher file

// load data from json file (without full path default location is /import)

call apoc.load.json("file:///Dependencies_Tree_Full_UnSorted.json") yield value

// merge loaded data into DB as nodes

merge (n:Node {nodeId: value.id}) on create set n.name = value.name

// using current data

with n, value

// unwind all of the node depends on nodes

unwind value.dependsOn as depOn

// merge loaded dependencies into DB as nodes

merge (e:Node {nodeId: depOn.id}) on create set e.name = depOn.name

// specify depends on relationship

merge (n)-[:Depends_On]-(e);

After building my image I then try to start the container and this is the output that I get

Changed password for user 'neo4j'.
Directories in use:
  home:         /var/lib/neo4j
  config:       /var/lib/neo4j/conf
  logs:         /logs
  plugins:      /var/lib/neo4j/plugins
  import:       /var/lib/neo4j/import
  data:         /var/lib/neo4j/data
  certificates: /var/lib/neo4j/certificates
  run:          /var/lib/neo4j/run
Starting Neo4j.
Started neo4j (pid 248). It is available at http://localhost:7474/
There may be a short delay until the server is ready.
See /logs/neo4j.log for current status.
starting data load ...
Invalid input '': expected
  "RETURN"
  "CREATE"
  "DELETE"
  "SET"
  "REMOVE"
  "DETACH"
  "MATCH"
  "WITH"
  "UNWIND"
  "USE"
  "CALL"
  "LOAD"
  "FROM"
  "FOREACH"
  "MERGE"
  "OPTIONAL"
  "USING" (line 1, column 1 (offset: 0))
"CALL apoc.load.json("file:///Dependencies_Tree_Full_UnSorted.json") yield value"
 ^

The error 'Invalid input' doesnt make sense to me and I cannot see what is wrong in my cypher file. I have copied and pasted the same cypher into a running neo4j docker container and it executes without issue.

The exact same code also works fine on another environment without any error but just this one environment is producing this error. I have tried googling but have found nothing yet that can explain what is wrong? Can anybody help?

1 ACCEPTED SOLUTION

Hello @andy.mcshane ,

I copied your dockerfile and ran in my machine. ofcourse my json is a dummy empty file. but it went through good

PS C:\scratch\2> docker build -t sss .
[+] Building 11.8s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                 0.1s 
 => => transferring dockerfile: 1.22kB                                                                                                               0.0s 
 => [internal] load .dockerignore                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => [internal] load metadata for docker.io/library/neo4j:4.2.2                                                                                      11.5s 
 => [auth] library/neo4j:pull token for registry-1.docker.io                                                                                         0.0s 
 => CANCELED https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar                                   0.1s 
 => [internal] load build context                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => CANCELED [1/4] FROM docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                        0.1s 
 => => resolve docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                 0.0s 
PS C:\scratch\2> docker build -t sss .
[+] Building 10.8s (8/9)
 => [internal] load build definition from Dockerfile                                                                                                 0.0s 

PS C:\scratch\2> docker build -t sss .
[+] Building 28.5s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                 0.0s 
 => => transferring dockerfile: 32B                                                                                                                  0.0s 
 => [internal] load .dockerignore                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => [internal] load metadata for docker.io/library/neo4j:4.2.2                                                                                      10.6s 
 => https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar                                            0.0s 
 => [internal] load build context                                                                                                                    0.1s 
 => => transferring context: 95B                                                                                                                     0.0s 
 => [1/4] FROM docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                14.2s 
 => => resolve docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                 0.0s 
 => => sha256:b9998d19c11696925915d7583990a0b9e239265533655abc5376d117ec9cfe3c 211B / 211B                                                           0.0s 
 => => sha256:eba5b958e0416b8e5d7b2ae81a51f33cfba67f5d9ea139a5ffd099b8956dfdec 197.20MB / 197.20MB                                                   0.0s 
 => => sha256:4b3572cb50798269301b38627abfe3ae37dc07cde039c93f8053d325a894df6d 499B / 499B                                                           0.0s 
 => => sha256:e743ea4f2800c12aff43ddae3bc6b11f50df481c93af664b0128b15d403abe63 118.85MB / 118.85MB                                                   0.0s 
 => => sha256:a076a628af6f7dcabc536bee373c0d9b48d9f0516788e64080c4e841746e6ce6 27.11MB / 27.11MB                                                     0.0s 
 => => sha256:f67e578fa0fa3f55cd18447b885689047dcf786097f8e7536912739dc489eae8 2.00kB / 2.00kB                                                       0.0s 

 => [2/4] ADD https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar /var/lib/neo4j/plugins           3.3s 
 => [3/4] COPY Dependencies_Tree_Full_UnSorted.json /var/lib/neo4j/import/                                                                           0.0s 
 => [4/4] COPY data_loader.cypher /var/lib/neo4j/import/                                                                                             0.1s 
 => exporting to image                                                                                                                               0.2s 
 => => exporting layers                                                                                                                              0.2s 
 => => writing image sha256:ca6ac5cda77a21cdc5e9da4c8230829a75649b4511e9b8e60582086b9f4a50e8                                                         0.0s 
 => => naming to docker.io/library/sss                                                                                                               0.0s 
PS C:\scratch\2> docker run -it sss
Changed password for user 'neo4j'.
Directories in use:
  home:         /var/lib/neo4j
  config:       /var/lib/neo4j/conf
  logs:         /logs
  plugins:      /var/lib/neo4j/plugins
  import:       /var/lib/neo4j/import
  data:         /var/lib/neo4j/data
  certificates: /var/lib/neo4j/certificates
  run:          /var/lib/neo4j/run
Starting Neo4j.
Started neo4j (pid 254). It is available at http://localhost:7474/
There may be a short delay until the server is ready.
See /logs/neo4j.log for current status.
We should be executing the cypher now?
2021-01-26 16:39:26.710+0000 INFO  Initializing system graph model for component 'security-users' with version -1 and status UNINITIALIZED
2021-01-26 16:39:26.722+0000 INFO  Setting up initial user from `auth.ini` file: neo4j
2021-01-26 16:39:26.723+0000 INFO  Creating new user 'neo4j' (passwordChangeRequired=false, suspended=false)
2021-01-26 16:39:26.740+0000 INFO  Setting version for 'security-users' to 2
2021-01-26 16:39:26.747+0000 INFO  After initialization of system graph model component 'security-users' have version 2 and status CURRENT
2021-01-26 16:39:26.754+0000 INFO  Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
2021-01-26 16:39:28.298+0000 INFO  Called db.clearQueryCaches(): Query cache already empty.
2021-01-26 16:39:28.371+0000 INFO  Bolt enabled on 0.0.0.0:7687.
2021-01-26 16:39:29.799+0000 INFO  Remote interface available at http://localhost:7474/
2021-01-26 16:39:29.800+0000 INFO  Started.

Can you check, if you have any trailing spaces etc etc ...

View solution in original post

5 REPLIES 5

Hello @andy.mcshane ,

I copied your dockerfile and ran in my machine. ofcourse my json is a dummy empty file. but it went through good

PS C:\scratch\2> docker build -t sss .
[+] Building 11.8s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                 0.1s 
 => => transferring dockerfile: 1.22kB                                                                                                               0.0s 
 => [internal] load .dockerignore                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => [internal] load metadata for docker.io/library/neo4j:4.2.2                                                                                      11.5s 
 => [auth] library/neo4j:pull token for registry-1.docker.io                                                                                         0.0s 
 => CANCELED https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar                                   0.1s 
 => [internal] load build context                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => CANCELED [1/4] FROM docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                        0.1s 
 => => resolve docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                 0.0s 
PS C:\scratch\2> docker build -t sss .
[+] Building 10.8s (8/9)
 => [internal] load build definition from Dockerfile                                                                                                 0.0s 

PS C:\scratch\2> docker build -t sss .
[+] Building 28.5s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                 0.0s 
 => => transferring dockerfile: 32B                                                                                                                  0.0s 
 => [internal] load .dockerignore                                                                                                                    0.1s 
 => => transferring context: 2B                                                                                                                      0.0s 
 => [internal] load metadata for docker.io/library/neo4j:4.2.2                                                                                      10.6s 
 => https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar                                            0.0s 
 => [internal] load build context                                                                                                                    0.1s 
 => => transferring context: 95B                                                                                                                     0.0s 
 => [1/4] FROM docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                14.2s 
 => => resolve docker.io/library/neo4j:4.2.2@sha256:c7f24de1dc1d2020ab24a884b8a39538937c1b14bc0ca1da3ddb2573b6fc412f                                 0.0s 
 => => sha256:b9998d19c11696925915d7583990a0b9e239265533655abc5376d117ec9cfe3c 211B / 211B                                                           0.0s 
 => => sha256:eba5b958e0416b8e5d7b2ae81a51f33cfba67f5d9ea139a5ffd099b8956dfdec 197.20MB / 197.20MB                                                   0.0s 
 => => sha256:4b3572cb50798269301b38627abfe3ae37dc07cde039c93f8053d325a894df6d 499B / 499B                                                           0.0s 
 => => sha256:e743ea4f2800c12aff43ddae3bc6b11f50df481c93af664b0128b15d403abe63 118.85MB / 118.85MB                                                   0.0s 
 => => sha256:a076a628af6f7dcabc536bee373c0d9b48d9f0516788e64080c4e841746e6ce6 27.11MB / 27.11MB                                                     0.0s 
 => => sha256:f67e578fa0fa3f55cd18447b885689047dcf786097f8e7536912739dc489eae8 2.00kB / 2.00kB                                                       0.0s 

 => [2/4] ADD https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.1/apoc-4.2.0.1-all.jar /var/lib/neo4j/plugins           3.3s 
 => [3/4] COPY Dependencies_Tree_Full_UnSorted.json /var/lib/neo4j/import/                                                                           0.0s 
 => [4/4] COPY data_loader.cypher /var/lib/neo4j/import/                                                                                             0.1s 
 => exporting to image                                                                                                                               0.2s 
 => => exporting layers                                                                                                                              0.2s 
 => => writing image sha256:ca6ac5cda77a21cdc5e9da4c8230829a75649b4511e9b8e60582086b9f4a50e8                                                         0.0s 
 => => naming to docker.io/library/sss                                                                                                               0.0s 
PS C:\scratch\2> docker run -it sss
Changed password for user 'neo4j'.
Directories in use:
  home:         /var/lib/neo4j
  config:       /var/lib/neo4j/conf
  logs:         /logs
  plugins:      /var/lib/neo4j/plugins
  import:       /var/lib/neo4j/import
  data:         /var/lib/neo4j/data
  certificates: /var/lib/neo4j/certificates
  run:          /var/lib/neo4j/run
Starting Neo4j.
Started neo4j (pid 254). It is available at http://localhost:7474/
There may be a short delay until the server is ready.
See /logs/neo4j.log for current status.
We should be executing the cypher now?
2021-01-26 16:39:26.710+0000 INFO  Initializing system graph model for component 'security-users' with version -1 and status UNINITIALIZED
2021-01-26 16:39:26.722+0000 INFO  Setting up initial user from `auth.ini` file: neo4j
2021-01-26 16:39:26.723+0000 INFO  Creating new user 'neo4j' (passwordChangeRequired=false, suspended=false)
2021-01-26 16:39:26.740+0000 INFO  Setting version for 'security-users' to 2
2021-01-26 16:39:26.747+0000 INFO  After initialization of system graph model component 'security-users' have version 2 and status CURRENT
2021-01-26 16:39:26.754+0000 INFO  Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
2021-01-26 16:39:28.298+0000 INFO  Called db.clearQueryCaches(): Query cache already empty.
2021-01-26 16:39:28.371+0000 INFO  Bolt enabled on 0.0.0.0:7687.
2021-01-26 16:39:29.799+0000 INFO  Remote interface available at http://localhost:7474/
2021-01-26 16:39:29.800+0000 INFO  Started.

Can you check, if you have any trailing spaces etc etc ...

And that is what makes it s strange. I have run the exact same code on another dev machine also and it worked as expected. I try creating the cypher script file from scratch again and type it all out again and see what happens.

Well it looks as if you are correct again, I have totally rewritten the cypher from scratch and the error has gone away so it must have been some spaces or hidden characters. Yet again i thank you for your kind help.

Hi @andy.mcshane , glad it worked. I always check-in the working code to GitHub and pull in any environments, that way its always the same with versioning. (sometimes i use it along with travis-ci).

clem
Graph Steward

There is an issue that error handling/reporting could be improved. It's pretty hard from this error message to tell where the error is occurring.