{"record":{"id":"8658a54344c22fb5","repo":"nocodb/nocodb","slug":"relation-column-not-found-on-column-column-title","errorCode":null,"errorMessage":"Relation column not found on column ${column.title}(${column.id})","messagePattern":"Relation column not found on column (.+?)\\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/nocodb-sdk/src/lib/unifiedMeta/getRollupColumn.ts","lineNumber":33,"sourceCode":"    columns: UnifiedMetaType.IColumn[];\n    getMeta: UnifiedMetaType.IGetModel;\n  }\n): Promise<UnifiedMetaType.IColumn> => {\n  const colOptions = await getColOptions<UnifiedMetaType.IRollupColumn>(\n    context,\n    { column }\n  );\n  if ('getRollupColumn' in colOptions) {\n    return await colOptions.getRollupColumn(context);\n  } else {\n    const relationColumn = columns.find(\n      (col) =>\n        col.id ===\n        (colOptions as UnifiedMetaType.IRollupColumn).fk_relation_column_id\n    );\n    if (!relationColumn) {\n      // TODO: better error type\n      throw new Error(\n        `Relation column not found on column ${column.title}(${column.id})`\n      );\n    }\n    const relationColOptions =\n      await getColOptions<UnifiedMetaType.ILinkToAnotherRecordColumn>(context, {\n        column: relationColumn,\n      });\n\n    const relatedTable = await getLTARRelatedTable(context, {\n      colOptions: relationColOptions,\n      getMeta,\n    });\n    const relatedTableColumns = await getColumns(context, {\n      model: relatedTable,\n    });\n    // TODO: possibly throw when column not found on relatedTableColumns\n    return relatedTableColumns.find(\n      (col) =>","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nocodb/nocodb/blob/d3caaf4e890acf64bd49b788cf6dc32b7644c895/packages/nocodb-sdk/src/lib/unifiedMeta/getRollupColumn.ts#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the relation (LinkToAnotherRecord) column referenced by fk_relation_column_id still exists in the table","Ensure the columns array passed to getRollupColumn includes ALL columns (not a filtered/partial set)","If the relation column was deleted, recreate it or delete the orphaned rollup column","Check for database inconsistencies — query nc_col_columns or equivalent for orphaned fk_relation_column_id values"],"exampleFix":"// before — columns array may be incomplete\nconst rollupCol = await getRollupColumn(context, {\n  column,\n  columns: partialColumns, // missing the relation column\n  getMeta,\n});\n\n// after — ensure all columns are loaded\nconst allColumns = await getColumns(context, { model });\nconst rollupCol = await getRollupColumn(context, {\n  column,\n  columns: allColumns,\n  getMeta,\n});","handlingStrategy":"validation","validationCode":"function validateRollupColumn(columns: IColumn[], fkRelationColumnId: string): boolean {\n  return columns.some((col) => col.id === fkRelationColumnId);\n}\n\n// Before calling getRollupColumn\nconst colOptions = await getColOptions(context, { column });\nif (!validateRollupColumn(columns, colOptions.fk_relation_column_id)) {\n  throw new Error(`Rollup column '${column.title}' references a deleted relation column. Please recreate or fix this column.`);\n}","typeGuard":"function hasValidRelationColumn(columns: IColumn[], colOptions: IRollupColumn): boolean {\n  return columns.some((c) => c.id === colOptions.fk_relation_column_id);\n}","tryCatchPattern":"try {\n  const rollupCol = await getRollupColumn(context, { column, columns, getMeta });\n} catch (e) {\n  if (e.message.includes('Relation column not found')) {\n    // The relation column was deleted — mark the rollup as broken\n    await markColumnAsBroken(column.id, 'Relation column deleted');\n  } else {\n    throw e;\n  }\n}","preventionTips":["When deleting LinkToAnotherRecord columns, cascade-delete or update dependent Rollup columns","Always pass the full columns array to getRollupColumn — never a filtered subset","Run data integrity checks that verify fk_relation_column_id references exist after schema migrations"],"tags":["rollup","column","relation","data-integrity","nocodb-sdk"],"backgroundTag":null,"analyzedSha":"d3caaf4e890acf64bd49b788cf6dc32b7644c895","analyzedAt":"2026-08-12T13:07:32.092Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}