cube-js/cube · error · UserError

Model '${model}' is not found

Error message

Model '${model}' is not found

What it means

After normalizing metric model references, loadMetricCubesFromNormalizedManifest looks up each model in manifest.nodes to build the cube's SQL. If a model key referenced by metrics is absent from manifest.nodes, it throws this UserError because the cube cannot know the table to select from.

Source

Thrown at packages/cubejs-dbt-schema-extension/src/Dbt.ts:234

          if (cubeDefs[modelName].dimensions.indexOf(dimension) === -1) {
            cubeDefs[modelName].dimensions.push(dimension);
          }
        });

        if (metricDef.timestamp) {
          if (cubeDefs[modelName].timeDimensions.indexOf(metricDef.timestamp) === -1) {
            cubeDefs[modelName].timeDimensions.push(metricDef.timestamp);
          }
        }
      },
    );

    const toExtend: { [cubeName: string]: any } = {};

    Object.keys(cubeDefs).forEach(model => {
      const modelDef = manifest.nodes[model];
      if (!modelDef) {
        throw new UserError(`Model '${model}' is not found`);
      }
      const cubeDef = {
        sql: () => `SELECT * FROM ${modelDef.relation_name ? modelDef.relation_name : `${this.compiler.contextQuery().escapeColumnName(modelDef.database)}.${this.compiler.contextQuery().escapeColumnName(modelDef.schema)}.${this.compiler.contextQuery().escapeColumnName(modelDef.name)}`}`,
        fileName: manifestPath,

        measures: cubeDefs[model].metrics.map(metric => ({
          [camelize(metric.name, true)]: {
            sql: () => metric.sql,
            type: mapMetricType(metric.type),
          },
        })).reduce((a, b) => ({ ...a, ...b }), {}),

        dimensions: {
          ...(cubeDefs[model].dimensions.map(dimension => ({
            [camelize(dimension, true)]: {
              sql: () => dimension,
              type: 'string',
            },

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Run 'dbt compile' without --select/--exclude filters that drop the model while keeping metrics that reference it
  2. Verify manifest.nodes contains an entry matching the normalized key (model.<package>.<model_name>) for each metric's model
  3. Regenerate manifest.json with a current dbt version compatible with the extension
  4. Check the metric's package_name matches the package of the referenced model

Example fix

// before
dbt compile --select +metrics
// after
dbt compile --select +metrics+  # include models the metrics depend on
Defensive patterns

Strategy: validation

Validate before calling

for (const [model, def] of Object.entries(cubeDefs)) {
  if (!manifest.nodes[model]) {
    throw new Error(`Metric references model '${model}' missing from manifest.nodes — compile without excluding it`);
  }
}

Try / catch

try {
  await dbt.loadMetricCubesFromDbtProject(projectPath, opts);
} catch (e) {
  if (/is not found$/.test(e.message)) {
    console.error(`Model missing from manifest; check dbt --select filters and package_name: ${e.message}`);
  } else { throw e; }
}

Prevention

When it happens

Trigger: A manifest.json whose metrics reference models not present in the nodes map (metrics exposed from packages whose models were excluded, --select/--exclude dbt selection filtering out the model, partial manifest), or the model reference normalization in step 223 producing a key (e.g. 'model.<package>.<name>') that does not match any nodes key.

Common situations: dbt run/compile with --select that omits the model but not its metrics; dbt packages where the manifest omits node details; dbt version mismatch between compile and the extension's expectations; manually truncated manifest.json.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/76f8b4b86e139667. Report an issue: GitHub.