cubejs-cli validate never exits when the data model contains a Python file

Open Beginner friendly
#11,908 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, python, typescript
Domain
cli

Research direction

Start in packages/cubejs-cli/src/command/validate.ts and compare its success path with displayError; cli.ts shows how the command is parsed. Reproduce with a Python model file using the provided cubejs-cli validate command, then verify that successful validation exits with code 0 while validation errors still exit non-zero.

Written by the indexing model from the issue text.

Description

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 cubejs-cli@1.7.34 validate --schema-path model

Output: ✅ 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 validate fails with Python (loadPythonContext) is not supported because you are using the fallback build of native extension and exits 1 before the runtime starts.
  • Suggested fix: process.exit(0) after the success log in validate.ts (or exit with process.exitCode set from the result), mirroring how displayError already exits on failure.
  • Workaround we use in CI: grep -m1 "Cube Schema is valid" < <(npx --yes cubejs-cli@1.7.34 validate --schema-path model 2>&1 | tee /dev/stderr).
Dominant language
Rust
Stars
20.9k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
201

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cube-js/cube

All issues in cube-js/cube

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.