{"record":{"id":"cd0ffd1370ab1280","repo":"n8n-io/n8n","slug":"property-propertypath-was-not-found-in-met-cd0ffd","errorCode":null,"errorMessage":"Property \"${propertyPath}\" was not found in \"${metadata.targetName}\". Make sure your query is correct.","messagePattern":"Property \"(.+?)\" was not found in \"(.+?)\"\\. Make sure your query is correct\\.","errorType":"exception","errorClass":"EntityPropertyNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts","lineNumber":3267,"sourceCode":"\t\t);\n\t}\n\n\tprotected buildSelect(\n\t\tselect: FindOptionsSelect<any>,\n\t\tmetadata: EntityMetadata,\n\t\talias: string,\n\t\tembedPrefix?: string,\n\t) {\n\t\tfor (let key in select) {\n\t\t\tif (select[key] === undefined || select[key] === false) continue;\n\n\t\t\tconst propertyPath = embedPrefix ? embedPrefix + '.' + key : key;\n\t\t\tconst column = metadata.findColumnWithPropertyPathStrict(propertyPath);\n\t\t\tconst embed = metadata.findEmbeddedWithPropertyPath(propertyPath);\n\t\t\tconst relation = metadata.findRelationWithPropertyPath(propertyPath);\n\n\t\t\tif (!embed && !column && !relation)\n\t\t\t\tthrow new EntityPropertyNotFoundError(propertyPath, metadata);\n\n\t\t\tif (column) {\n\t\t\t\tthis.selects.push(alias + '.' + propertyPath);\n\t\t\t\t// this.addSelect(alias + \".\" + propertyPath);\n\t\t\t} else if (embed) {\n\t\t\t\tthis.buildSelect(select[key] as FindOptionsSelect<any>, metadata, alias, propertyPath);\n\n\t\t\t\t// } else if (relation) {\n\t\t\t\t//     const joinAlias = alias + \"_\" + relation.propertyName;\n\t\t\t\t//     const existJoin = this.joins.find(join => join.alias === joinAlias);\n\t\t\t\t//     if (!existJoin) {\n\t\t\t\t//         this.joins.push({\n\t\t\t\t//             type: \"left\",\n\t\t\t\t//             select: false,\n\t\t\t\t//             alias: joinAlias,\n\t\t\t\t//             parentAlias: alias,\n\t\t\t\t//             relationMetadata: relation\n\t\t\t\t//         });","sourceCodeStart":3249,"sourceCodeEnd":3285,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts#L3249-L3285","documentation":"Thrown as EntityPropertyNotFoundError from buildSelect when a key in a FindOptionsSelect map is neither an embedded, a column, nor a relation on the entity metadata. The strict lookup `findColumnWithPropertyPathStrict` refuses to silently ignore unknown fields, turning typos into hard failures.","triggerScenarios":"Calling `repo.find({ select: { misSpelled: true } })`, passing a select map built from stale type definitions after a column rename, or generating select keys dynamically from user input that includes a non-column name.","commonSituations":"Schema migration renaming/dropping a column while the select map still references the old name; copy-paste of select maps across entities; DTO-to-select mappers that include keys which are relations/computed fields not mapped as columns.","solutions":["Align the select map with current entity metadata; remove or rename the offending key.","Derive select keys from the entity's column names (e.g. Object.keys(metadata.columns)) rather than hand-maintaining them.","After a migration, search for the renamed column in all select/where/order maps."],"exampleFix":"// before\nrepo.find({ select: { firstName: true, surName: true } }); // column is lastName\n// after\nrepo.find({ select: { firstName: true, lastName: true } });","handlingStrategy":"validation","validationCode":"function sanitizeSelect<T>(meta: EntityMetadata, select: Record<string, boolean>): FindOptionsSelect<T> {\n  const out: Record<string, boolean> = {};\n  for (const [k, v] of Object.entries(select)) {\n    const isCol = !!meta.findColumnWithPropertyPathStrict(k);\n    const isEmbed = !!meta.findEmbeddedWithPropertyPath(k);\n    const isRel = !!meta.findRelationWithPropertyPath(k);\n    if (isCol || isEmbed || isRel) out[k] = v;\n    else throw new Error(`select key '${k}' is not a column/embed/relation`);\n  }\n  return out as FindOptionsSelect<T>;\n}","typeGuard":"function isKnownProperty(meta: EntityMetadata, key: string): boolean {\n  return !!meta.findColumnWithPropertyPathStrict(key)\n      || !!meta.findEmbeddedWithPropertyPath(key)\n      || !!meta.findRelationWithPropertyPath(key);\n}","tryCatchPattern":"try {\n  return await repo.find({ select });\n} catch (e) {\n  if (e?.name === 'EntityPropertyNotFoundError') throw new BadRequestException(e.message);\n  throw e;\n}","preventionTips":["Derive select maps from the entity's column names instead of hand-maintaining them.","After a migration, search for the old column name across find/select call sites.","Validate user-supplied select fields against an allowlist before querying."],"tags":["typeorm","query-builder","validation","metadata","find-options"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}