nocodb/nocodb · error · Error

Relation column not found on column ${column.title}(${column

Error message

Relation column not found on column ${column.title}(${column.id})

What it means

Thrown by getRollupColumn when processing a Rollup-type column and the fk_relation_column_id stored in the column's options does not match any column ID in the model's columns array. The relation column is the LinkToAnotherRecord column that connects the rollup to its source table. If it cannot be found, the rollup is broken because the link it depends on is missing.

Source

Thrown at packages/nocodb-sdk/src/lib/unifiedMeta/getRollupColumn.ts:33

    columns: UnifiedMetaType.IColumn[];
    getMeta: UnifiedMetaType.IGetModel;
  }
): Promise<UnifiedMetaType.IColumn> => {
  const colOptions = await getColOptions<UnifiedMetaType.IRollupColumn>(
    context,
    { column }
  );
  if ('getRollupColumn' in colOptions) {
    return await colOptions.getRollupColumn(context);
  } else {
    const relationColumn = columns.find(
      (col) =>
        col.id ===
        (colOptions as UnifiedMetaType.IRollupColumn).fk_relation_column_id
    );
    if (!relationColumn) {
      // TODO: better error type
      throw new Error(
        `Relation column not found on column ${column.title}(${column.id})`
      );
    }
    const relationColOptions =
      await getColOptions<UnifiedMetaType.ILinkToAnotherRecordColumn>(context, {
        column: relationColumn,
      });

    const relatedTable = await getLTARRelatedTable(context, {
      colOptions: relationColOptions,
      getMeta,
    });
    const relatedTableColumns = await getColumns(context, {
      model: relatedTable,
    });
    // TODO: possibly throw when column not found on relatedTableColumns
    return relatedTableColumns.find(
      (col) =>

View on GitHub (pinned to d3caaf4e89)

Solutions

  1. Verify the relation (LinkToAnotherRecord) column referenced by fk_relation_column_id still exists in the table
  2. Ensure the columns array passed to getRollupColumn includes ALL columns (not a filtered/partial set)
  3. If the relation column was deleted, recreate it or delete the orphaned rollup column
  4. Check for database inconsistencies — query nc_col_columns or equivalent for orphaned fk_relation_column_id values

Example fix

// before — columns array may be incomplete
const rollupCol = await getRollupColumn(context, {
  column,
  columns: partialColumns, // missing the relation column
  getMeta,
});

// after — ensure all columns are loaded
const allColumns = await getColumns(context, { model });
const rollupCol = await getRollupColumn(context, {
  column,
  columns: allColumns,
  getMeta,
});
Defensive patterns

Strategy: validation

Validate before calling

function validateRollupColumn(columns: IColumn[], fkRelationColumnId: string): boolean {
  return columns.some((col) => col.id === fkRelationColumnId);
}

// Before calling getRollupColumn
const colOptions = await getColOptions(context, { column });
if (!validateRollupColumn(columns, colOptions.fk_relation_column_id)) {
  throw new Error(`Rollup column '${column.title}' references a deleted relation column. Please recreate or fix this column.`);
}

Type guard

function hasValidRelationColumn(columns: IColumn[], colOptions: IRollupColumn): boolean {
  return columns.some((c) => c.id === colOptions.fk_relation_column_id);
}

Try / catch

try {
  const rollupCol = await getRollupColumn(context, { column, columns, getMeta });
} catch (e) {
  if (e.message.includes('Relation column not found')) {
    // The relation column was deleted — mark the rollup as broken
    await markColumnAsBroken(column.id, 'Relation column deleted');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: A Rollup column references a LinkToAnotherRecord (relation) column that was deleted. The columns array passed to getRollupColumn is incomplete (lazy-loaded columns where the relation column hasn't been fetched). Database inconsistency where fk_relation_column_id points to a stale ID after a column migration or schema change.

Common situations: Deleting a LinkToAnotherRecord column that a Rollup depends on without cascading the delete to the Rollup. Schema migration or import that breaks column ID references. Race condition in lazy column loading where not all columns are present. Manual database edits that orphan rollup column options.

Related errors


AI-assisted analysis of nocodb/nocodb@d3caaf4e89 (2026-08-12). Data as JSON: /api/errors/8658a54344c22fb5. Report an issue: GitHub.