{"record":{"id":"3f99b6d504d93020","repo":"cube-js/cube","slug":"name-is-not-defined","errorCode":null,"errorMessage":"${name} is not defined.","messagePattern":"(.+?) is not defined\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/helpers.ts","lineNumber":54,"sourceCode":"    });\n  });\n}\n\n// Executes `command` in `dir`, returns the error code. Preserves working directory.\nexport function execInDir(dir: string, command: string): number {\n  const crtDir = process.cwd();\n  try {\n    process.chdir(dir);\n    const result = shell.exec(command);\n    return result.code;\n  } finally {\n    process.chdir(crtDir);\n  }\n}\n\nexport function assertNonNullable<T>(name: string, x: T): asserts x is NonNullable<T> {\n  if (x === undefined || x === null) {\n    throw new Error(`${name} is not defined.`);\n  }\n}\n\n// If x is nullable, throws and error, else return x with a nonnulable type.\nexport function checkNonNullable<T>(name: string, x: T): NonNullable<T> {\n  assertNonNullable(name, x);\n  return x;\n}\n\nexport async function streamToArray<T>(stream: Readable): Promise<T[]> {\n  const result: T[] = [];\n  for await (const x of stream) {\n    result.push(x);\n  }\n  return result;\n}\n\n// https://nodejs.org/api/stream.html#readablewrapstream","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/helpers.ts#L36-L72","documentation":"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.","triggerScenarios":"Thrown at packages/cubejs-backend-shared/src/helpers.ts:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}