You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by ji...@apache.org on 2026/10/14 19:14:31 UTC
(hugegraph-toolchain) branch master updated: fix(loader): reject missing values before Flink (#819)
This is an automated email from the ASF dual-hosted git repository.
imbajin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hugegraph-toolchain.git
The following commit(s) were added to refs/heads/master by this push:
new 2f1b96a47 fix(loader): reject missing values before Flink (#819)
2f1b96a47 is described below
commit 2f1b96a47b69f87948d00d2842e65908d3a93462
Author: imbajin <ji...@apache.org>
AuthorDate: Thu Oct 15 03:14:26 2026 +0800
fix(loader): reject missing values before Flink (#819)
- reuse the existing option parser before CDC submission
- preserve engine and Loader argument boundaries
- cover trailing missing values and document rejection
---
.../static/bin/hugegraph-flinkcdc-loader.sh | 22 +++++++++++++++-------
hugegraph-loader/docs/flink-cdc-java17.md | 1 +
.../src/test/scripts/flink-launcher.test.cjs | 14 ++++++++++----
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/hugegraph-loader/assembly/static/bin/hugegraph-flinkcdc-loader.sh b/hugegraph-loader/assembly/static/bin/hugegraph-flinkcdc-loader.sh
index ce812fbaf..d86237678 100755
--- a/hugegraph-loader/assembly/static/bin/hugegraph-flinkcdc-loader.sh
+++ b/hugegraph-loader/assembly/static/bin/hugegraph-flinkcdc-loader.sh
@@ -32,22 +32,30 @@ fi
# Without a separator all arguments belong to Loader. To set Flink options:
# hugegraph-flinkcdc-loader.sh -p 1 -- --file mapping.json --graph hugegraph
-ENGINE_PARAMS=()
-HUGEGRAPH_PARAMS=("$@")
+FLINK_ARGS=()
+LOADER_ARGS=("$@")
for arg in "$@"; do
if [[ "$arg" == "--" ]]; then
- HUGEGRAPH_PARAMS=()
+ LOADER_ARGS=()
while [[ "$1" != "--" ]]; do
- ENGINE_PARAMS+=("$1")
+ FLINK_ARGS+=("$1")
shift
done
shift
- HUGEGRAPH_PARAMS=("$@")
+ LOADER_ARGS=("$@")
break
fi
done
+# Validate Loader options without rewriting their original argument boundaries.
+(
+ # The shared parser permits empty engine arrays on Bash 3.
+ set +u
+ source "$BIN_DIR/get-params.sh"
+ get_params "${LOADER_ARGS[@]}"
+)
+
# Do not echo arguments: they can contain authentication credentials.
-exec "$FLINK_HOME/bin/flink" run ${ENGINE_PARAMS[@]+"${ENGINE_PARAMS[@]}"} \
+exec "$FLINK_HOME/bin/flink" run ${FLINK_ARGS[@]+"${FLINK_ARGS[@]}"} \
-c org.apache.hugegraph.loader.flink.HugeGraphFlinkCDCLoader \
- "${ASSEMBLY_JARS[0]}" ${HUGEGRAPH_PARAMS[@]+"${HUGEGRAPH_PARAMS[@]}"}
+ "${ASSEMBLY_JARS[0]}" ${LOADER_ARGS[@]+"${LOADER_ARGS[@]}"}
diff --git a/hugegraph-loader/docs/flink-cdc-java17.md b/hugegraph-loader/docs/flink-cdc-java17.md
index 1b92b3b2e..3469f3b55 100644
--- a/hugegraph-loader/docs/flink-cdc-java17.md
+++ b/hugegraph-loader/docs/flink-cdc-java17.md
@@ -27,6 +27,7 @@ bin/hugegraph-flinkcdc-loader.sh --file mapping.json --graph hugegraph
```
Place Flink options before `--` and Loader options after it. Paths with spaces remain individual arguments; the launcher does not print argument values.
+Missing values for recognized Loader options, such as `--password` or `--file`, are rejected before invoking Flink.
```bash
bin/hugegraph-flinkcdc-loader.sh -p 1 -- \
diff --git a/hugegraph-loader/src/test/scripts/flink-launcher.test.cjs b/hugegraph-loader/src/test/scripts/flink-launcher.test.cjs
index cfa9cccbe..581876186 100644
--- a/hugegraph-loader/src/test/scripts/flink-launcher.test.cjs
+++ b/hugegraph-loader/src/test/scripts/flink-launcher.test.cjs
@@ -18,7 +18,7 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { spawnSync } = require('node:child_process');
-const { mkdtempSync, mkdirSync, copyFileSync, writeFileSync, readFileSync, realpathSync, rmSync } = require('node:fs');
+const { mkdtempSync, mkdirSync, copyFileSync, writeFileSync, readFileSync, realpathSync, rmSync, existsSync } = require('node:fs');
const { tmpdir } = require('node:os');
const { join, resolve } = require('node:path');
@@ -30,6 +30,7 @@ test('CDC launcher keeps argument boundaries and does not expose arguments', t =
mkdirSync(join(root, 'flink/bin'), { recursive: true });
const script = join(root, 'loader/bin/hugegraph-flinkcdc-loader.sh');
copyFileSync(resolve(__dirname, '../../../assembly/static/bin/hugegraph-flinkcdc-loader.sh'), script);
+ copyFileSync(resolve(__dirname, '../../../assembly/static/bin/get-params.sh'), join(root, 'loader/bin/get-params.sh'));
const argsFile = join(root, 'args');
writeFileSync(join(root, 'flink/bin/flink'), '#!/bin/bash\nprintf "%s\\0" "$@" > "$PROBE_ARGS"\n' +
'exit "${PROBE_EXIT_CODE:-0}"\n', { mode: 0o755 });
@@ -52,9 +53,14 @@ test('CDC launcher keeps argument boundaries and does not expose arguments', t =
assert.deepEqual(readFileSync(argsFile, 'utf8').split('\0').slice(0, -1),
['run', '-c', 'org.apache.hugegraph.loader.flink.HugeGraphFlinkCDCLoader', jar,
'--file', 'mapping.json', '--graph', 'fixture']);
- const rejected = run(['--file'], { PROBE_EXIT_CODE: '2' });
- assert.equal(rejected.status, 2, rejected.stderr);
- assert.equal(rejected.stdout, '');
+ for (const option of ['--password', '--file']) {
+ rmSync(argsFile, { force: true });
+ const rejected = run([option]);
+ assert.equal(rejected.status, 2, `${option}: ${rejected.stderr}`);
+ assert.match(rejected.stderr, new RegExp(`Missing value for ${option}`));
+ assert.equal(rejected.stdout, '');
+ assert.equal(existsSync(argsFile), false, 'Flink must not run for a missing Loader option value');
+ }
assert.notEqual(run([], { FLINK_HOME: '' }).status, 0);
writeFileSync(join(root, 'loader/lib/apache-hugegraph-loader-extra-shaded.jar'), 'fixture');
assert.notEqual(run([]).status, 0);