Skip to content

Commit

Permalink
Fixes #2824: Extend the error message for export procedures to also p…
Browse files Browse the repository at this point in the history
…oint out stream:true (#2887) (#2914)

Co-authored-by: Giuseppe Villani <[email protected]>
  • Loading branch information
neo4j-oss-build and vga91 authored May 25, 2022
1 parent fadea9d commit eb0ab7c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/apoc/ApocConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public enum UuidFormatType { hex, base64 }
));
private static final String DEFAULT_PATH = ".";
private static final String CONFIG_DIR = "config-dir=";
public static final String EXPORT_TO_FILE_ERROR = "Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf";
public static final String EXPORT_TO_FILE_ERROR = "Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf.\n" +
"Otherwise, if you are running in a cloud environment without filesystem access, use the `{stream:true}` config and null as a 'file' parameter to stream the export back to your client.\n" +
"Note that the stream mode cannot be used with the apoc.export.xls.* procedures.";

private final Config neo4jConfig;
private final Log log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.neo4j.test.rule.DbmsRule;
import org.neo4j.test.rule.ImpermanentDbmsRule;

import static apoc.ApocConfig.EXPORT_TO_FILE_ERROR;
import static org.junit.Assert.assertEquals;
import static org.neo4j.configuration.SettingImpl.newBuilder;
import static org.neo4j.configuration.SettingValueParsers.BOOL;
Expand Down Expand Up @@ -52,8 +53,7 @@ public void shouldNotExportCSVData() {
TestUtil.testCall(db, statement, (res) -> {});
} catch (RuntimeException e) {
String expectedMessage = "Failed to invoke procedure `apoc.export.csv.all`: " +
"Caused by: java.lang.RuntimeException: Export to files not enabled, " +
"please set apoc.export.file.enabled=true in your apoc.conf";
"Caused by: java.lang.RuntimeException: " + EXPORT_TO_FILE_ERROR;
assertEquals(expectedMessage, e.getMessage());
throw e;
}
Expand Down Expand Up @@ -94,8 +94,7 @@ public void shouldNotExportCypherStatements() {
TestUtil.testCall(db, statement, (res) -> {});
} catch (RuntimeException e) {
String expectedMessage = "Failed to invoke procedure `apoc.export.cypher.all`: " +
"Caused by: java.lang.RuntimeException: Export to files not enabled, " +
"please set apoc.export.file.enabled=true in your apoc.conf";
"Caused by: java.lang.RuntimeException: " + EXPORT_TO_FILE_ERROR;
assertEquals(expectedMessage, e.getMessage());
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import static apoc.ApocConfig.APOC_EXPORT_FILE_ENABLED;
import static apoc.ApocConfig.APOC_IMPORT_FILE_ENABLED;
import static apoc.ApocConfig.EXPORT_TO_FILE_ERROR;
import static apoc.ApocConfig.apocConfig;
import static apoc.util.BinaryTestUtil.fileToBinary;
import static apoc.util.MapUtil.map;
Expand Down Expand Up @@ -464,7 +465,7 @@ public void testExportGraphGraphMLTypesWithNoExportConfig() throws Exception {
} catch (QueryExecutionException e) {
Throwable except = ExceptionUtils.getRootCause(e);
TestCase.assertTrue(except instanceof RuntimeException);
assertEquals("Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf", except.getMessage());
assertEquals(EXPORT_TO_FILE_ERROR, except.getMessage());
throw e;
}
}
Expand Down
4 changes: 3 additions & 1 deletion docs/asciidoc/modules/ROOT/partials/enableFileExport.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ apoc.export.file.enabled=true
If we try to use any of the export procedures without having first set this property, we'll get the following error message:

|===
| Failed to invoke procedure: Caused by: java.lang.RuntimeException: Export to files not enabled, please set apoc.export.file.enabled=true in your neo4j.conf
| Failed to invoke procedure: Caused by: java.lang.RuntimeException: Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf.
Otherwise, if you are running in a cloud environment without filesystem access, use the `{stream:true}` config and null as a 'file' parameter to stream the export back to your client.
Note that the stream mode cannot be used with the apoc.export.xls.* procedures.
|===

Export files are written to the `import` directory, which is defined by the `server.directories.import` property.
Expand Down
4 changes: 3 additions & 1 deletion docs/asciidoc/modules/ROOT/partials/enableS3Export.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ apoc.export.file.enabled=true
If we try to use any of the export procedures without having first set this property, we'll get the following error message:

|===
| Failed to invoke procedure: Caused by: java.lang.RuntimeException: Export to files not enabled, please set apoc.export.file.enabled=true in your neo4j.conf
| Failed to invoke procedure: Caused by: java.lang.RuntimeException: Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf.
Otherwise, if you are running in a cloud environment without filesystem access, you can use the `{stream:true}` config and null as a 'file' parameter to stream the export back to your client.
Note that the stream mode cannot be used with the apoc.export.xls.* procedures.
|===

== Using S3 protocol
Expand Down

0 comments on commit eb0ab7c

Please sign in to comment.