n8n-io/n8n · error · Error
${key} column was not found in the ${metadata.name} entity.
Error message
${key} column was not found in the ${metadata.name} entity. What it means
FindOptionsUtils (FindManyOptions branch) iterates options.order keys and resolves each via metadata.findColumnWithPropertyPath. Any key without a matching column throws `${key} column was not found in the ${metadata.name} entity.` Ordering is by column property name, not DB column name, and relations are not valid order keys here.
Source
Thrown at packages/@n8n/typeorm/src/find-options/FindOptionsUtils.ts:215
} else if (options.loadRelationIds instanceof Object) {
qb.loadAllRelationIds(options.loadRelationIds as any);
}
if (options.where)
qb.where(options.where);
if ((options as FindManyOptions<T>).skip)
qb.skip((options as FindManyOptions<T>).skip!);
if ((options as FindManyOptions<T>).take)
qb.take((options as FindManyOptions<T>).take!);
if (options.order)
Object.keys(options.order).forEach(key => {
const order = ((options as FindOneOptions<T>).order as any)[key as any];
if (!metadata.findColumnWithPropertyPath(key))
throw new Error(`${key} column was not found in the ${metadata.name} entity.`);
switch (order) {
case 1:
qb.addOrderBy(qb.alias + "." + key, "ASC");
break;
case -1:
qb.addOrderBy(qb.alias + "." + key, "DESC");
break;
case "ASC":
qb.addOrderBy(qb.alias + "." + key, "ASC");
break;
case "DESC":
qb.addOrderBy(qb.alias + "." + key, "DESC");
break;
}
});
return qb;View on GitHub (pinned to 5ac6606e81)
Solutions
- Use the @Column property name (camelCase typically), not the DB column name.
- For relations, add a join and order by the joined alias instead.
- Update call sites when renaming any column used in order clauses.
- Grep `order:` usages after column renames.
Example fix
// before
await repo.find({ order: { created_at: 'DESC' } });
// after
@Entity()
class User { @Column() createdAt!: Date; }
await repo.find({ order: { createdAt: 'DESC' } }); Defensive patterns
Strategy: validation
Validate before calling
function validateOrder<Entity>(meta: import('@n8n/typeorm').EntityMetadata<Entity>, order: Record<string, any>): void {
for (const key of Object.keys(order)) {
if (!meta.findColumnWithPropertyPath(key)) {
throw new Error(`order key ${key} is not a mapped column on ${meta.name}`);
}
}
}
validateOrder(connection.getMetadata(Entity), options.order ?? {});
await repo.find(options); Type guard
function isOrderableKey<Entity>(meta: import('@n8n/typeorm').EntityMetadata<Entity>, key: string): boolean {
return !!meta.findColumnWithPropertyPath(key);
} Prevention
- Use property names (camelCase) in order, not DB column names.
- For relation columns, join first and order by the joined alias.
- Type order keys as keyof Entity.
- Grep `order:` when renaming columns.
When it happens
Trigger: Passing `order: { created_at: 'DESC' }` (DB column) instead of `{ createdAt: 'DESC' }` (property); ordering by a relation field without selecting/joining it; ordering by a getter or virtual property; ordering by a column removed in a refactor; ordering by a snake_case column when the entity uses camelCase.
Common situations: Snake-case leak from raw SQL mindset; rename missing call sites; ordering by a computed field that exists on the type but isn't @Column; embedded/nested paths not fully qualified.
Related errors
- ${select} column was not found in the ${metadata.name} entit
- Relation "${notFoundRelations[0]}" was not found; please che
- Property "${propertyPath}" was not found in "${metadata.targ
- Property "${propertyPath}" was not found in "${metadata.targ
- Column "${columnName}" was not found in table "${metadata.na
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/f3b9ce597c70144a.
Report an issue: GitHub.