cube-js/cube · error · UserError
Hierarchy '${it.name}' not found in cube '${cubeName}'
Error message
Hierarchy '${it.name}' not found in cube '${cubeName}' What it means
While preparing cube hierarchies, Cube resolves each hierarchy level's member alias into a canonical name via hierarchyPathToName. If the joined alias 'cube.member' has no entry, the level references a member that doesn't exist, so it throws a UserError at compile time.
Source
Thrown at packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts:593
.map(it => {
const levels = it.levels.filter(level => {
const member = cube.includedMembers.find(m => m.memberPath === level);
if (member && member.type !== 'dimensions') {
const memberName = level.split('.')[1] || level;
errorReporter.error(`Only dimensions can be part of a hierarchy. Please remove the '${memberName}' member from the '${it.name}' hierarchy.`);
} else if (member) {
return includedMemberPaths.includes(level);
}
return null;
})
.filter(Boolean);
const aliasMember = [cubeName, it.name].join('.');
const name = hierarchyPathToName[aliasMember];
if (!name) {
throw new UserError(`Hierarchy '${it.name}' not found in cube '${cubeName}'`);
}
return {
// Title might be overridden in the view
title: cube.hierarchies?.[it.name]?.override?.title || it.title,
...it,
aliasMember,
name,
levels
};
})
.filter(it => it.levels.length);
cube.evaluatedHierarchies = [...(cube.evaluatedHierarchies || []), ...filteredHierarchies];
}
}
cube.evaluatedHierarchies = (cube.evaluatedHierarchies || []).map((hierarchy) => ({View on GitHub (pinned to 7d981676b3)
Solutions
- Fix hierarchy level names to match existing dimension/measure names exactly (with correct casing)
- Re-run compilation and check for other member-not-found errors to locate the offending level
- Remove or update hierarchies referencing deleted/renamed members
Example fix
// before
hierarchies: { Location: { levels: [location.city, location.regoin] } }
// after
hierarchies: { Location: { levels: [location.city, location.region] } } Defensive patterns
Strategy: try-catch
Validate before calling
const cube = evaluator.cubeFromPath(cubeName);
for (const level of hierarchy.levels || []) {
if (!(level in (cube.dimensions || {})) && !(level in (cube.measures || {}))) throw new Error(`Hierarchy level ${level} missing in ${cubeName}`);
} Try / catch
try { compiler.compile(); } catch (e) { if (e instanceof UserError && e.message.includes('not found in cube')) { console.error(e.message); } throw e; } Prevention
- Reference hierarchy levels by copying exact member names
- Run schema compilation in CI to catch broken hierarchies early
- Update hierarchies whenever dimensions are renamed/removed
When it happens
Trigger: Declaring a hierarchy whose levels reference dimensions/measures that don't exist in the cube (or in the joined cube for shared hierarchies/views), e.g. hierarchies: { Location: { levels: [NonexistentDim] } }.
Common situations: Typos in hierarchy level names; renaming/deleting a dimension without updating hierarchies; hierarchies defined in a view referencing members not exposed by the underlying cube; schema compilation after partial edits.
Related errors
- Unable to create schema, Druid does not support it
- MySQL can not work with table names longer than 64 symbols.
- Oracle can not work with table names longer than 128 symbols
- PostgreSQL can not work with table names longer than 63 symb
- Can not construct joins for the query, potential loop detect
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/b797ffa0302256db.
Report an issue: GitHub.