cube-js/cube · error · Error
${name} is not defined.
Error message
${name} is not defined. What it means
Generic assertion helper in helpers.ts: assertNonNullable throws this sentinel Error when the passed value is undefined or null. It is an internal invariant check, not domain validation — it fires wherever Cube code requires a value it believes was already ensured, so the named value being missing indicates an upstream logic or configuration gap.
Source
Thrown at packages/cubejs-backend-shared/src/helpers.ts:54
});
});
}
// Executes `command` in `dir`, returns the error code. Preserves working directory.
export function execInDir(dir: string, command: string): number {
const crtDir = process.cwd();
try {
process.chdir(dir);
const result = shell.exec(command);
return result.code;
} finally {
process.chdir(crtDir);
}
}
export function assertNonNullable<T>(name: string, x: T): asserts x is NonNullable<T> {
if (x === undefined || x === null) {
throw new Error(`${name} is not defined.`);
}
}
// If x is nullable, throws and error, else return x with a nonnulable type.
export function checkNonNullable<T>(name: string, x: T): NonNullable<T> {
assertNonNullable(name, x);
return x;
}
export async function streamToArray<T>(stream: Readable): Promise<T[]> {
const result: T[] = [];
for await (const x of stream) {
result.push(x);
}
return result;
}
// https://nodejs.org/api/stream.html#readablewrapstreamView on GitHub (pinned to 7d981676b3)
Solutions
- Trace the caller that passed null/undefined for `name` and fix the upstream initialization or lookup.
- Ensure configuration or earlier lookups that produce this value actually succeeded before it is consumed.
- Use checkNonNullable if you want a value-unwrapping variant instead of a bare assertion.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/cubejs-backend-shared/src/helpers.ts:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/3f99b6d504d93020.
Report an issue: GitHub.