{"record":{"id":"cc6b605136a9efac","repo":"cube-js/cube","slug":"undefined-cube-cube","errorCode":null,"errorMessage":"Undefined cube '${cube}'","messagePattern":"Undefined cube '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/QueryFactory.ts","lineNumber":9,"sourceCode":"export class QueryFactory {\n  public constructor(\n    private cubeToQueryClass: Record<string, any>,\n  ) {\n  }\n\n  public createQuery(cube: string, compilers: any, queryOptions: any) {\n    if (!(cube in this.cubeToQueryClass)) {\n      throw new Error(`Undefined cube '${cube}'`);\n    }\n    const QueryClass = this.cubeToQueryClass[cube];\n    if (!QueryClass) {\n      throw new Error(`Undefined dbType or dialectClass for '${cube}'`);\n    }\n    return new QueryClass(compilers, queryOptions);\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/QueryFactory.ts#L1-L18","documentation":"QueryFactory.createQuery is keyed by cube name; it throws when the requested cube has no mapping in cubeToQueryClass. This means the cube name passed doesn't match any cube registered in the factory (built from the compiled schema's dbType/dialect mapping).","triggerScenarios":"Calling queryFactory.createQuery(cube, compilers, queryOptions) with a cube string not present as a key in cubeToQueryClass — e.g. a misspelled cube name or a cube absent from the compiled schema.","commonSituations":"Typo in the cube name when creating a query programmatically; querying a cube that failed to compile or was renamed; using a cube name with different casing.","solutions":["Check the exact cube name against your schema files (name matches the cube/view declaration)","Recompile/reload the schema to ensure the cube exists and compiled successfully","Verify the cube's dbType/dialect is defined so the factory registers a mapping for it"],"exampleFix":"// before\nfactory.createQuery('Orders ', compilers, options);\n// after\nfactory.createQuery('Orders', compilers, options);","handlingStrategy":"validation","validationCode":"const compilerApi = await prepareCompiler({ schemaPath });\nconst cubes = Object.keys(compilerApi.cubeEvaluator.cubeNames());\nif (!cubes.includes(cube)) throw new Error(`Cube ${cube} not in schema; known: ${cubes.join(',')}`);","typeGuard":null,"tryCatchPattern":"try { return factory.createQuery(cube, compilers, options); } catch (e) { if (e.message.startsWith('Undefined cube')) { /* surface list of valid cubes */ } throw e; }","preventionTips":["Use compiler-generated cube lists instead of hardcoded strings","Fail fast at config load when a referenced cube is missing","Watch for renames in schema files via linting"],"tags":["cube","configuration","schema"],"backgroundTag":"undefined-cube","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}