{"record":{"id":"93282be09f140e29","repo":"n8n-io/n8n","slug":"relation-notfoundrelations-0-was-not-found","errorCode":null,"errorMessage":"Relation \"${notFoundRelations[0]}\" was not found; please check if it is correct and really exists in your entity.","messagePattern":"Relation \"(.+?)\" was not found; please check if it is correct and really exists in your entity\\.","errorType":"exception","errorClass":"FindRelationsNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/find-options/FindOptionsUtils.ts","lineNumber":135,"sourceCode":"                    throw new TypeORMError(`${select} column was not found in the ${metadata.name} entity.`);\n\n                const columns = metadata.findColumnsWithPropertyPath(`${select}`);\n\n                for (const column of columns) {\n                    qb.addSelect(qb.alias + \".\" + column.propertyPath);\n                }\n            });\n        }\n\n        if (options.relations) {\n            // Copy because `applyRelationsRecursively` modifies it\n            const allRelations = [...options.relations];\n            this.applyRelationsRecursively(qb, allRelations, qb.expressionMap.mainAlias!.name, qb.expressionMap.mainAlias!.metadata, \"\");\n            // recursive removes found relations from allRelations array\n            // if there are relations left in this array it means those relations were not found in the entity structure\n            // so, we give an exception about not found relations\n            if (allRelations.length > 0)\n                throw new FindRelationsNotFoundError(allRelations);\n        }\n\n        if (options.join) {\n            if (options.join.leftJoin)\n                Object.keys(options.join.leftJoin).forEach(key => {\n                    qb.leftJoin(options.join!.leftJoin![key], key);\n                });\n\n            if (options.join.innerJoin)\n                Object.keys(options.join.innerJoin).forEach(key => {\n                    qb.innerJoin(options.join!.innerJoin![key], key);\n                });\n\n            if (options.join.leftJoinAndSelect)\n                Object.keys(options.join.leftJoinAndSelect).forEach(key => {\n                    qb.leftJoinAndSelect(options.join!.leftJoinAndSelect![key], key);\n                });\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/find-options/FindOptionsUtils.ts#L117-L153","documentation":"FindOptionsUtils applies options.relations recursively, removing matched relations from a working array. Anything left unmatched means the caller asked for a relation that doesn't exist on the entity graph; FindRelationsNotFoundError is thrown with the leftover names (singular form shown when one remains).","triggerScenarios":"Passing `relations: ['tags']` when the entity has no `tags` relation; typos in the relation path; requesting nested relations like `'profile.avatar'` where `profile` exists but `avatar` isn't a relation of Profile; mixing relation names with column names; relation was renamed in code but call sites weren't updated.","commonSituations":"Rename of a relation missing some call sites; copy-paste between entities; switch from eager loading to explicit relations where the field is a @Column not a @ManyToOne; nested paths where a segment isn't itself a relation.","solutions":["Check the @OneToMany/@ManyToOne/@ManyToMany decorators on the entity and use the exact relation property name.","For nested relations, confirm each segment of the dotted path is a relation on the corresponding entity.","Update call sites after renaming any relation property.","If you only want the FK column, use `select` not `relations`."],"exampleFix":"// before\nawait repo.find({ relations: ['tag'] }); // entity has `tags`\n\n// after\n@Entity()\nclass Post { @ManyToMany(() => Tag) tags!: Tag[]; }\nawait repo.find({ relations: ['tags'] });","handlingStrategy":"validation","validationCode":"function validateRelations<Entity>(meta: import('@n8n/typeorm').EntityMetadata<Entity>, relations: readonly string[]): void {\n  for (const r of relations) {\n    const segs = r.split('.');\n    let m = meta;\n    for (const seg of segs) {\n      const rel = m.relations.find(x => x.propertyPath === seg);\n      if (!rel) throw new Error(`relation ${r} not found on ${m.name}`);\n      m = rel.inverseEntityMetadata;\n    }\n  }\n}\nvalidateRelations(connection.getMetadata(Entity), options.relations ?? []);\nawait repo.findOne(options);","typeGuard":"function isRelationPath<Entity>(meta: import('@n8n/typeorm').EntityMetadata<Entity>, path: string): boolean {\n  let m = meta; const segs = path.split('.');\n  for (const seg of segs) {\n    const rel = m.relations.find(x => x.propertyPath === seg);\n    if (!rel) return false;\n    m = rel.inverseEntityMetadata;\n  }\n  return true;\n}","tryCatchPattern":null,"preventionTips":["Match the relation property name exactly.","For nested paths, verify each segment is itself a relation.","Grep `relations:` when renaming a relation.","Use select (not relations) for plain FK columns."],"tags":["typeorm","find-options","relations","metadata"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}