{"record":{"id":"7903aa74c1b97061","repo":"TanStack/table","slug":"aggregationfn-id-id-for-column-column-id","errorCode":null,"errorMessage":"aggregationFn id '${id}' for column '${column.id}' is duplicated","messagePattern":"aggregationFn id '(.+?)' for column '(.+?)' is duplicated","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/table-core/src/features/row-aggregation/rowAggregationFeature.utils.ts","lineNumber":308,"sourceCode":"  for (let i = 0; i < option.length; i++) {\n    const item = option[i]\n    const id =\n      typeof item === 'string'\n        ? item\n        : isAggregationFnDescriptor(item)\n          ? item.id\n          : undefined\n\n    if (id === undefined) {\n      warn(\n        `aggregationFn at index ${i} for column '${column.id}' needs a stable id`,\n      )\n      resolved.push({ aggregationFn: undefined, id: undefined })\n      continue\n    }\n\n    if (ids[id]! > 1) {\n      warn(`aggregationFn id '${id}' for column '${column.id}' is duplicated`)\n      resolved.push({ aggregationFn: undefined, id })\n      continue\n    }\n\n    const ref = isAggregationFnDescriptor(item) ? item.aggregationFn : item\n    resolved.push({\n      aggregationFn: resolveAggregationFn(column, ref),\n      id,\n    })\n  }\n\n  return finish(resolved)\n}\n\nfunction getSubRowResult(\n  subRowValue: unknown,\n  isMultiple: boolean,\n  id: string | undefined,","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/table-core/src/features/row-aggregation/rowAggregationFeature.utils.ts#L290-L326","documentation":"When a column's `aggregation` option is an array of aggregation-fn ids or descriptors, each entry must have a unique stable id. During resolution in column_getAggregationFns, any id that appears more than once in the array is dropped (its aggregationFn resolves to undefined) and this dev warning is fired, because duplicated ids would collide in the aggregated result object and make output ambiguous.","triggerScenarios":"Setting `columnDef.aggregation` to an array that repeats the same string id, e.g. `['sum', 'sum']`, or two descriptors with the same `id`, e.g. `[{id: 'agg', aggregationFn: fnA}, {id: 'agg', aggregationFn: fnB}]`. Built-in id strings like 'sum', 'mean', 'count' are also checked for duplicates.","commonSituations":"Copy-pasting an aggregation entry and forgetting to change its id; combining a string id with a descriptor that carries the same id; generating the aggregation array programmatically and reusing a key; extending built-ins like 'count' twice for different row scopes.","solutions":["Give every entry in the aggregation array a unique id (rename the duplicate descriptor's `id`).","If you need the same aggregation logic twice, wrap it in a descriptor with a distinct id, e.g. {id: 'sumRows', aggregationFn: 'sum'}.","Merge or drop the redundant aggregation entry if both do the same job.","Read the resolved value by its unique id instead of relying on positional duplicates."],"exampleFix":"// before\naggregation: ['sum', 'sum']\n\n// after\naggregation: ['sum', 'mean']\n// or with descriptors:\naggregation: [\n  { id: 'sumRows', aggregationFn: 'sum' },\n  { id: 'sumLeafRows', aggregationFn: customLeafSum },\n]","handlingStrategy":"validation","validationCode":"function assertUniqueAggregationIds(aggregation) {\n  const ids = aggregation\n    .map((a) => (typeof a === 'string' ? a : a?.id))\n    .filter((id) => id !== undefined)\n  const dupes = ids.filter((id, i) => ids.indexOf(id) !== i)\n  if (dupes.length) throw new Error(`Duplicate aggregation ids: ${[...new Set(dupes)].join(', ')}`)\n}\nassertUniqueAggregationIds(columnDef.aggregation ?? [])","typeGuard":"function hasUniqueAggregationIds(option) {\n  if (!Array.isArray(option)) return true\n  const ids = option\n    .map((a) => (typeof a === 'string' ? a : a?.id))\n    .filter((id) => id !== undefined)\n  return new Set(ids).size === ids.length\n}","tryCatchPattern":null,"preventionTips":["Treat every aggregation-array entry as needing a globally unique id; name custom descriptors after what they compute.","Run the uniqueness check in unit tests for column definitions.","Prefer built-in string ids from the official list and never repeat one within a column.","Check the dev console during development — the library warns instead of throwing."],"tags":["aggregation","duplicate-key","configuration","dev-warning"],"backgroundTag":"duplicate-identifier","analyzedSha":"d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6","analyzedAt":"2026-08-28T21:52:44.679Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}