{"record":{"id":"b1f8c3278fd122d5","repo":"angular/components","slug":"could-not-find-a-matching-row-definition-for-the-p","errorCode":null,"errorMessage":"Could not find a matching row definition for the provided row data: ${JSON.stringify(data)}","messagePattern":"Could not find a matching row definition for the provided row data: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cdk/table/table.ts","lineNumber":1340,"sourceCode":"   */\n  _getRowDefs(data: T, dataIndex: number): CdkRowDef<T>[] {\n    if (this._rowDefs.length === 1) {\n      return [this._rowDefs[0]];\n    }\n\n    let rowDefs: CdkRowDef<T>[] = [];\n    if (this.multiTemplateDataRows) {\n      rowDefs = this._rowDefs.filter(def => !def.when || def.when(dataIndex, data));\n    } else {\n      let rowDef =\n        this._rowDefs.find(def => def.when && def.when(dataIndex, data)) || this._defaultRowDef;\n      if (rowDef) {\n        rowDefs.push(rowDef);\n      }\n    }\n\n    if (!rowDefs.length && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw getTableMissingMatchingRowDefError(data);\n    }\n\n    return rowDefs;\n  }\n\n  private _getEmbeddedViewArgs(\n    renderRow: RenderRow<T>,\n    index: number,\n  ): _ViewRepeaterItemInsertArgs<RowContext<T>> {\n    const rowDef = renderRow.rowDef;\n    const context: RowContext<T> = {$implicit: renderRow.data};\n    return {\n      templateRef: rowDef.template,\n      context,\n      index,\n    };\n  }\n","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk/table/table.ts#L1322-L1358","documentation":"During rendering the table collects row definitions whose `when` predicate matches each data item (or the default def). If no row def matched for a particular data item, it throws with the JSON of that data. This happens when only conditional row defs exist and an item satisfies none of them.","triggerScenarios":"_getAllRenderRows / rowDefs gathering: for a data item, every *matRowDef has a when predicate that returned false and there is no default (no-when) row def, leaving rowDefs.length === 0.","commonSituations":"A row type in the data (e.g. a discriminated union member like 'unknown') not covered by any when predicate; predicates narrowed by an earlier filter change; data source updated at runtime to include new shapes the templates don't handle.","solutions":["Add a default row def without `when` as a catch-all: <tr mat-row *matRowDef=\"let row; columns: cols\"></tr>","Extend one predicate to cover the unmatched data shape","Enable [multiTemplateDataRows]=\"true\" if items should match multiple defs and fix predicates accordingly","Log/filter data items that fail all predicates during development"],"exampleFix":"// before — only conditional defs, item {type:'other'} matches none\n<tr mat-row *matRowDef=\"let row; columns: cols; when: isUser\"></tr>\n// after — add fallback default def\n<tr mat-row *matRowDef=\"let row; columns: cols; when: isUser\"></tr>\n<tr mat-row *matRowDef=\"let row; columns: genericCols\"></tr>","handlingStrategy":"validation","validationCode":"const predicates = rowDefs.map(d => d.when).filter(Boolean);\nconst unmatched = data.filter(item =>\n  !rowDefs.some(d => d.when ? d.when(item) : true));\nif (unmatched.length) throw new Error(`No row def matches: ${JSON.stringify(unmatched[0])}`);","typeGuard":"function allItemsMatchARowDef<T>(data: T[], rowDefs: {when?: (d: T) => boolean}[]): data is T[] {\n  return data.every(item => rowDefs.some(d => d.when ? d.when(item) : true));\n}","tryCatchPattern":"try {\n  this.cdr.detectChanges();\n} catch (e) {\n  if (/matching row definition/.test(e.message)) {\n    console.error('Add a default (no-when) row def or broaden a when predicate.');\n  }\n}","preventionTips":["Always include one default row def as a catch-all","Cover every member of a discriminated union with a when predicate","Re-validate predicates when data shapes change"],"tags":["angular","cdk-table","row-def","when-predicate"],"backgroundTag":"no-matching-row-definition","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}