Skip to content

Commit c7f7b5d

Browse files
committed
fix: throw meaningful error when backup on invalid URL
Fixed issue ArcadeData#3716
1 parent 5a0f06b commit c7f7b5d

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

integration/src/main/java/com/arcadedb/integration/backup/BackupSettings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public void validateSettings() {
4646
if (format == null)
4747
throw new IllegalArgumentException("Missing backup format");
4848

49+
if (file != null && (file.startsWith("http://") || file.startsWith("https://") || file.startsWith("classpath://")))
50+
throw new IllegalArgumentException(
51+
"Backup to remote URLs is not supported. Only local file paths and 'file://' URLs are allowed");
52+
4953
if (directory != null && file != null) {
5054
final String f = file.startsWith("file://") ? file.substring("file://".length()) : file;
5155
if (f.contains("..") || f.contains(File.separator))

integration/src/test/java/com/arcadedb/integration/backup/BackupDatabaseTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.nio.file.Path;
2929

3030
import static org.assertj.core.api.Assertions.assertThat;
31+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3132

3233
class BackupDatabaseTest extends TestHelper {
3334

@@ -45,6 +46,22 @@ void backup() {
4546
assertThat(result.<String>getProperty("backupFile")).isEqualTo("file://test-backup.zip");
4647
}
4748

49+
@Test
50+
void backupWithHttpUrlShouldFail() {
51+
assertThatThrownBy(() -> database.command("sql", "backup database http://example.com/backup.zip"))
52+
.rootCause()
53+
.isInstanceOf(IllegalArgumentException.class)
54+
.hasMessageContaining("not supported");
55+
}
56+
57+
@Test
58+
void backupWithHttpsUrlShouldFail() {
59+
assertThatThrownBy(() -> database.command("sql", "backup database https://example.com/backup.zip"))
60+
.rootCause()
61+
.isInstanceOf(IllegalArgumentException.class)
62+
.hasMessageContaining("not supported");
63+
}
64+
4865
@Test
4966
void backupEncryption() {
5067
ResultSet resultSet = database.command("sql", "backup database file://test-backup.zip with encryptionKey = 'SuperSecretKey'");

0 commit comments

Comments
 (0)