{"record":{"id":"b68025e142650aac","repo":"TanStack/table","slug":"corecolumnsfeature-require-an-id-when-using-an-acc","errorCode":null,"errorMessage":"coreColumnsFeature require an id when using an accessorFn","messagePattern":"coreColumnsFeature require an id when using an accessorFn","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/table-core/src/core/columns/constructColumn.ts","lineNumber":94,"sourceCode":"          result = result?.[key]\n          if (process.env.NODE_ENV === 'development' && result === undefined) {\n            console.warn(\n              `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`,\n            )\n          }\n        }\n\n        return result as TValue\n      }\n    } else {\n      accessorFn = (originalRow: TData) =>\n        (originalRow as any)[resolvedColumnDef.accessorKey]\n    }\n  }\n\n  if (!id) {\n    if (process.env.NODE_ENV === 'development') {\n      throw new Error(\n        resolvedColumnDef.accessorFn\n          ? `coreColumnsFeature require an id when using an accessorFn`\n          : `coreColumnsFeature require an id when using a non-string header`,\n      )\n    }\n    throw new Error()\n  }\n\n  // Create column with shared prototype for memory efficiency\n  const columnPrototype = getColumnPrototype(table)\n  const column = Object.create(columnPrototype) as Column_CoreProperties<\n    TFeatures,\n    TData,\n    TValue\n  >\n\n  // Only assign instance-specific properties\n  column.accessorFn = accessorFn","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/table-core/src/core/columns/constructColumn.ts#L76-L112","documentation":"constructColumn in packages/table-core derives a column id from accessorKey or header string. When a column uses accessorFn (a function accessor) there is no key to infer an id from, so if no explicit id is given the library throws this dev-mode error rather than generating a duplicate-prone implicit id.","triggerScenarios":"Passing a columnDef with accessorFn: (row) => ... but no id property, in development (NODE_ENV === 'development').","commonSituations":"Defining data-only columns with function accessors in an array of columnDefs; renaming accessorKey to accessorFn while removing id; dynamically built column configs.","solutions":["Add an explicit id to the column definition alongside accessorFn.","If the column also has a string header usable as id, set id to the same stable string used elsewhere (row.getCellValue, grouping keys).","Verify all generated/dynamic column defs always include id when accessorFn is present."],"exampleFix":"// before\n{ accessorFn: (row) => row.user.name, header: 'User' }\n// after\n{ id: 'user.name', accessorFn: (row) => row.user.name, header: 'User' }","handlingStrategy":"validation","validationCode":"function assertColumnHasId(def) {\n  if (!def.id && def.accessorFn) {\n    throw new Error('Column with accessorFn requires an explicit id: ' + (def.header ?? def))\n  }\n}\ncolumns.forEach(assertColumnHasId) // before createTable/columns feature init","typeGuard":"function hasRequiredId(def: ColumnDef<any>): def is ColumnDef<any> & { id: string } {\n  return typeof def.id === 'string' && def.id.length > 0\n}","tryCatchPattern":"try {\n  const column = constructColumn(id, originalColumnDef, resolvedColumnDef, table)\n} catch (e) {\n  if ((e as Error).message.includes('require an id')) {\n    console.error('Column definition missing id:', originalColumnDef)\n  } else throw e\n}","preventionTips":["Always set id when using accessorFn","Validate column defs at build time with a schema/lint rule","Keep ids stable and unique across refactors"],"tags":["columns","configuration","missing-id"],"backgroundTag":"column-missing-id","analyzedSha":"d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6","analyzedAt":"2026-08-28T21:52:44.679Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}