cubejs-cli validate never exits when the data model contains a Python file
Describe the bug
cubejs-cli validate never exits after printing ✅ Cube Schema is valid when the data model contains a Python file. The verdict is printed within seconds, then the process stays alive until killed (in our Cloud Build it ran into the build timeout with a valid schema).
Cause, as far as I can tell: packages/cubejs-cli/src/command/validate.ts returns after console.log('✅ Cube Schema is valid') without process.exit, and cli.ts ends with program.parse(process.argv). With a YAML-only model the event loop drains and Node exits. Once loadPythonContext has started the embedded Python runtime, something keeps the loop alive, so the process never ends. The failure path is unaffected because displayError ends with process.exit(1).
To Reproduce
On Linux x64 with libpython so the Python-enabled native build is selected (ldconfig -v must list libpython3.11):
docker run --rm -it node:22-bookworm bash
apt-get update && apt-get install -y libpython3.11
mkdir -p /repro/model && cd /repro
cat > model/globals.py <<'PY'
from cube import TemplateContext
template = TemplateContext()
PY
cat > model/orders.yml <<'YML'
cubes:
- name: orders
sql: select 1 as id
measures:
- name: count
type: count
YML
npx --yes [email protected] validate --schema-path modelOutput: ✅ Cube Schema is valid, then the process hangs. Delete model/globals.py and rerun: same output, process exits immediately.
Expected behavior Process exits with code 0 after the success message (and non-zero on validation errors), so the command can be used as a CI gate.
Screenshots n/a
Minimally reproducible Cube Schema See the two files above; any Python file in the model directory triggers it, the cube itself is irrelevant.
Version:
cubejs-cli 1.7.34, @cubejs-backend/native 1.7.34 (native-linux-x64-glibc-3.11), Node 22.23.2, Debian bookworm. validate.ts on master has the same shape, so presumably also 1.7.40.
Additional context
- Not reproducible on macOS: the native package only ships the fallback build there, so
validatefails withPython (loadPythonContext) is not supported because you are using the fallback build of native extensionand exits 1 before the runtime starts. - Suggested fix:
process.exit(0)after the success log invalidate.ts(or exit withprocess.exitCodeset from the result), mirroring howdisplayErroralready exits on failure. - Workaround we use in CI:
grep -m1 "Cube Schema is valid" < <(npx --yes [email protected] validate --schema-path model 2>&1 | tee /dev/stderr).
Source: cube-js/cube