{"record":{"id":"7e150791bf97c9ae","repo":"angular/components","slug":"duplicate-column-definition-name-provided-colu","errorCode":null,"errorMessage":"Duplicate column definition name provided: \"${columnDef.name}\".","messagePattern":"Duplicate column definition name provided: \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cdk/table/table.ts","lineNumber":1125,"sourceCode":"        return {data, rowDef, dataIndex};\n      }\n    });\n  }\n\n  /** Update the map containing the content's column definitions. */\n  private _cacheColumnDefs() {\n    this._columnDefsByName.clear();\n\n    const columnDefs = mergeArrayAndSet(\n      this._getOwnDefs(this._contentColumnDefs),\n      this._customColumnDefs,\n    );\n    columnDefs.forEach(columnDef => {\n      if (\n        this._columnDefsByName.has(columnDef.name) &&\n        (typeof ngDevMode === 'undefined' || ngDevMode)\n      ) {\n        throw getTableDuplicateColumnNameError(columnDef.name);\n      }\n      this._columnDefsByName.set(columnDef.name, columnDef);\n    });\n  }\n\n  /** Update the list of all available row definitions that can be used. */\n  private _cacheRowDefs() {\n    this._headerRowDefs = mergeArrayAndSet(\n      this._getOwnDefs(this._contentHeaderRowDefs),\n      this._customHeaderRowDefs,\n    );\n    this._footerRowDefs = mergeArrayAndSet(\n      this._getOwnDefs(this._contentFooterRowDefs),\n      this._customFooterRowDefs,\n    );\n    this._rowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentRowDefs), this._customRowDefs);\n\n    // After all row definitions are determined, find the row definition to be considered default.","sourceCodeStart":1107,"sourceCodeEnd":1143,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk/table/table.ts#L1107-L1143","documentation":"Two or more CdkColumnDef instances registered with the table share the same `name`. The table keeps a map of column name -> definition (_columnDefsByName) and refuses ambiguous duplicates because it could not resolve which cell template to use. Thrown during content init / column def registration in dev mode.","triggerScenarios":"_syncColumnDefs → columnDefs.forEach when this._columnDefsByName.has(columnDef.name) is true while registering column defs, e.g. two <ng-container matColumnDef=\"name\"> blocks in the same table.","commonSituations":"Copy-pasting a column and forgetting to change matColumnDef value; two tables nested or sharing template content causing double registration; refactoring where a column id was duplicated by merge conflict.","solutions":["Rename one of the duplicate matColumnDef/cdkColumnDef values so each name in a table is unique","Search the table's template for repeated matColumnDef=\"x\" values (e.g. duplicate of 'name')","If columns come from a *ngFor over a config array, ensure the config has unique ids","Make sure the same columnDef template isn't projected into the table twice"],"exampleFix":"// before\n<ng-container matColumnDef=\"name\">...</ng-container>\n<ng-container matColumnDef=\"name\">...</ng-container>\n// after\n<ng-container matColumnDef=\"name\">...</ng-container>\n<ng-container matColumnDef=\"description\">...</ng-container>","handlingStrategy":"validation","validationCode":"const ids = Array.from(el.querySelectorAll('[matColumnDef]')).map(c => c.getAttribute('matColumnDef'));\nconst dupes = ids.filter((id, i) => ids.indexOf(id) !== i);\nif (dupes.length) throw new Error(`Duplicate matColumnDef ids: ${dupes.join(',')}`);","typeGuard":"function hasUniqueColumnIds(ids: string[]): ids is string[] {\n  return new Set(ids).size === ids.length;\n}","tryCatchPattern":"try {\n  this.cdr.detectChanges();\n} catch (e) {\n  if (/Duplicate column definition name/.test(e.message)) {\n    console.error('Rename one of the duplicated matColumnDef ids:', e.message);\n  }\n}","preventionTips":["Lint/check template for duplicate matColumnDef values","Generate columns from config arrays with enforced-unique ids","Avoid projecting the same column template into multiple tables"],"tags":["angular","cdk-table","duplicate-column","template"],"backgroundTag":"duplicate-column-definition","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}