{"record":{"id":"be3564b0460ca2b7","repo":"n8n-io/n8n","slug":"cannot-find-relation-propertypath-wrong-relati-be3564","errorCode":null,"errorMessage":"Cannot find relation ${propertyPath}. Wrong relation specified for @RelationId decorator.","messagePattern":"Cannot find relation (.+?)\\. Wrong relation specified for @RelationId decorator\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/metadata/RelationIdMetadata.ts","lineNumber":106,"sourceCode":"\t\t}\n\t}\n\n\t// ---------------------------------------------------------------------\n\t// Public Builder Methods\n\t// ---------------------------------------------------------------------\n\n\t/**\n\t * Builds some depend relation id properties.\n\t * This builder method should be used only after entity metadata, its properties map and all relations are build.\n\t */\n\tbuild() {\n\t\tconst propertyPath =\n\t\t\ttypeof this.relationNameOrFactory === 'function'\n\t\t\t\t? this.relationNameOrFactory(this.entityMetadata.propertiesMap)\n\t\t\t\t: this.relationNameOrFactory;\n\t\tconst relation = this.entityMetadata.findRelationWithPropertyPath(propertyPath);\n\t\tif (!relation)\n\t\t\tthrow new TypeORMError(\n\t\t\t\t`Cannot find relation ${propertyPath}. Wrong relation specified for @RelationId decorator.`,\n\t\t\t);\n\n\t\tthis.relation = relation;\n\t}\n}\n","sourceCodeStart":88,"sourceCodeEnd":113,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/metadata/RelationIdMetadata.ts#L88-L113","documentation":"Thrown by RelationIdMetadata.build when the relation name or factory passed to @RelationId does not resolve to any relation via findRelationWithPropertyPath. Identical mechanism to the RelationCount check: it accepts a string or a propertiesMap factory, resolves it during build, and throws TypeORMError if nothing matches.","triggerScenarios":"Using @RelationId(() => Entity, 'missingRel') or a factory returning a non-existent path on the owning entity.","commonSituations":"Relation renamed/deleted without updating @RelationId arguments; pointing @RelationId at a non-relation field; refactor moving a relation between entities.","solutions":["Confirm the path passed to @RelationId names an actual @OneToMany/@ManyToOne/@ManyToMany/@OneToOne relation on the entity.","Sync the string/factory with the current relation property name after renames.","Remove the @RelationId property if the underlying relation no longer exists."],"exampleFix":"// before\n@RelationId((post) => post.author)\nauthorId: number;\n// but the relation property is actually named 'owner'\n\n// after\n@RelationId((post) => post.owner)\nauthorId: number;","handlingStrategy":"validation","validationCode":"function validateRelationIds(dataSource: DataSource): string[] {\n  const problems: string[] = [];\n  for (const meta of dataSource.entityMetadatas) {\n    const relationPaths = new Set(meta.relations.map((r) => r.propertyPath));\n    for (const ri of meta.relationIds) {\n      const target =\n        typeof ri.relationNameOrFactory === 'function'\n          ? ri.relationNameOrFactory(meta.propertiesMap)\n          : ri.relationNameOrFactory;\n      if (!relationPaths.has(target)) {\n        problems.push(`${meta.targetName}.@RelationId -> missing relation '${target}'`);\n      }\n    }\n  }\n  return problems;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await dataSource.initialize();\n} catch (err) {\n  if (err.message.includes('Wrong relation specified for @RelationId')) {\n    // surface the bad relation path\n  }\n  throw err;\n}","preventionTips":["Reference relation names through a single shared constant used by both the @XxxRelation decorator and the @RelationId.","Run the post-init RelationId validator in CI.","On relation deletion, audit every @RelationId that pointed at it."],"tags":["relation-id","relation","metadata","startup"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}