neo4j-contrib / neo4j-apoc-procedures

Awesome Procedures On Cypher for Neo4j - codenamed "apoc"                     If you like it, please ★ above ⇧            

Home Page:https://neo4j.com/labs/apoc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to invoke procedure `apoc.import.graphml`: Caused by: java.net.MalformedURLException: unknown protocol: d

mlnrt opened this issue · comments

Expected Behavior (Mandatory)

Neo4j APOC procedures are able to import and export from/to an absolute Window path

Actual Behavior (Mandatory)

I have a GitHub repository with DVC to track and pull data files. When pulling the project and data I need the code to directly import (and export) GML data from the repository's data folder, without having to instruct people to move file to the Neo4j project import folder.

The apoc.conf file is set as follows:

apoc.export.file.enabled=true
apoc.import.file.enabled=true
apoc.import.file.use_neo4j_config=false

Neo4j APOC procedures are unable to export and import from an absolute Windows path, throwing a protocol error on the driver letter.
When running the command
CALL apoc.import.graphml("D:\code\my_repo\data\neo4j\all_members.gml", {})
Neo4j throws the following error:
Failed to invoke procedure apoc.import.graphml: Caused by: java.net.MalformedURLException: unknown protocol: d

The same error is thrown using the apoc.export.graphml procedure.

How to Reproduce the Problem

Steps (Mandatory)

On Windows

  1. Take any GML file and put it somewhere else than the Neo4j project import folder
  2. Set the apoc.conf file as displayed above
  3. create a database CREATE DATABASE mydb
  4. run CALL apoc.import.graphml("<the full path to the GML file>\<gml file name>", {})

Specifications (Mandatory)

Versions

  • OS: Windows 10
  • Neo4j Desktop: 1.5.7
  • Neo4j: 5.4.0
  • Neo4j-Apoc: 5.4.1

Hi there! thanks for writing in :) You need to write file: at the start, otherwise the url tries to interpret the D: as the url protocol.

Try: CALL apoc.import.graphml("file:D:\code\my_repo\data\neo4j\all_members.gml", {})

Hope this helps!

Hello @gem-neo4j , thank you for replying so quickly.
And OMG... it looks like I missed the obvious!
I reread the documentation and it does show up in one of the example but I missed it.
But the documentation shows this example CALL apoc.import.graphml("file://simple.graphml", {})
So should it be file:D:\... or file://D:\... ?

OK I have two other problems with both file:D:\... and file://D:\...

  1. I get now this error: Failed to invoke procedure apoc.export.graphml.all: Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4
  2. It looks like the apoc proceudre is taking the "\n" and "\f" in my path CALL apoc.export.graphml.all("file:D:\code\my_repo\data\neo4j\full_graph.gml", {}) as a new line as I get the error message as below:
Failed to invoke procedure 'apoc.export.graphml.all': Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file://D:\code\my_repo\data
eo4jull_graph.gml

If I myself escape all the "" in the path, i.e. replace
CALL apoc.export.graphml.all("file:D:\code\my_repo\data\neo4j\full_graph.gml", {})
by
CALL apoc.export.graphml.all("file:D:\\code\\my_repo\\data\\neo4j\\full_graph.gml", {})

Then I am just left with the first error:

Failed to invoke procedure `apoc.export.graphml.all`: Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file://D:\code\my_repo\data\neo4j\full_graph.gml

Hi! So it looks like the fix I supplied you works only for apoc.import.graphml, there does indeed seem to be a bug with apoc.export.graphml.all which is not working with Windows paths. I will create a bug ticket for my team to fix :) Thank you for reporting!

@gem-neo4j thank you for creating that bug ticket and let me know if there is anything I can do, or information I can provide to help

@gem-neo4j
BTW, I think the bug with Windows path is also affecting apoc.import.graphml
Have a great week-end