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

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

Open
mlnrt opened this issue Feb 27, 2023 · 7 comments
Labels
core-functionality Adding new procedure, function or signature to APOC core

Comments

@mlnrt
Copy link

mlnrt commented Feb 27, 2023

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
@gem-neo4j
Copy link
Contributor

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!

@mlnrt
Copy link
Author

mlnrt commented Feb 28, 2023

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:\... ?

@mlnrt
Copy link
Author

mlnrt commented Feb 28, 2023

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

@mlnrt
Copy link
Author

mlnrt commented Feb 28, 2023

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

@gem-neo4j
Copy link
Contributor

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!

@mlnrt
Copy link
Author

mlnrt commented Mar 1, 2023

@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

@mlnrt
Copy link
Author

mlnrt commented Mar 3, 2023

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

@vga91 vga91 added the core-functionality Adding new procedure, function or signature to APOC core label Apr 19, 2023
@jexp jexp moved this to Todo in APOC Extended Larus Sep 21, 2023
@vga91 vga91 moved this from Todo to Blocked in APOC Extended Larus Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-functionality Adding new procedure, function or signature to APOC core
Projects
Status: Core issues
Development

No branches or pull requests

3 participants