n8n-io/n8n · error · Error
Cannot find alias for property ${propertyPath}
Error message
Cannot find alias for property ${propertyPath} What it means
QueryBuilder property-path resolver throws when, after exhausting the path segments, no alias is found at all for the given propertyPath. Unlike 1078 (relation exists but not joined), this fires when the root alias itself or an intermediate alias cannot be resolved — the path does not map to any alias/metadata pair in the query. It is followed by an EntityPropertyNotFoundError check if an alias is found but columns are missing.
Source
Thrown at packages/@n8n/typeorm/src/query-builder/QueryBuilder.ts:1158
(joinAttr) => joinAttr.relationPropertyPath === part,
);
if (!joinAttr?.alias) {
const fullRelationPath = root.length > 0 ? `${root.join('.')}.${part}` : part;
throw new Error(`Cannot find alias for relation at ${fullRelationPath}`);
}
alias = joinAttr.alias;
root.push(...part.split('.'));
propertyPathParts.shift();
continue;
}
break;
}
if (!alias) {
throw new Error(`Cannot find alias for property ${propertyPath}`);
}
// Remaining parts are combined back and used to find the actual property path
const aliasPropertyPath = propertyPathParts.join('.');
const columns = alias.metadata.findColumnsWithPropertyPath(aliasPropertyPath);
if (!columns.length) {
throw new EntityPropertyNotFoundError(propertyPath, alias.metadata);
}
return [alias, root, columns];
}
/**
* Creates a property paths for a given ObjectLiteral.
*/
protected createPropertyPath(View on GitHub (pinned to 5ac6606e81)
Solutions
- Verify the alias prefix in the property path matches a registered alias (the main alias from from/select, or a join alias).
- Prefix property paths with the correct alias: 'u.email' not 'email' when using a non-default alias.
- Ensure createQueryBuilder(Entity, 'u') sets the alias you reference.
- Add the missing join that introduces the alias.
Example fix
// before
const qb = dataSource.createQueryBuilder(User, 'u')
.andWhere('users.email = :e', { e }); // 'users' alias not registered
// after
const qb = dataSource.createQueryBuilder(User, 'u')
.andWhere('u.email = :e', { e }); Defensive patterns
Strategy: validation
Validate before calling
function aliasExists(qb: { expressionMap: { aliases: Array<{ name: string }>; mainAlias?: { name: string } } }, name: string): boolean {
const aliases = [...qb.expressionMap.aliases.map(a => a.name), ...(qb.expressionMap.mainAlias ? [qb.expressionMap.mainAlias.name] : [])];
return aliases.includes(name);
}
if (!aliasExists(qb, aliasName)) throw new Error(`alias '${aliasName}' is not registered; check from/select/join aliases`); Type guard
function aliasIsRegistered(qb: { expressionMap: { aliases: Array<{ name: string }>; mainAlias?: { name: string } } }, name: string): boolean {
const names = new Set([...qb.expressionMap.aliases.map(a => a.name), qb.expressionMap.mainAlias?.name].filter(Boolean) as string[]);
return names.has(name);
} Prevention
- Prefix property paths with a registered alias (the from/select alias or a join alias).
- Verify alias spelling and case against the builder's aliases.
- Ensure createQueryBuilder(Entity, 'alias') sets the alias you reference.
- Add the missing join that introduces the alias before referencing its columns.
When it happens
Trigger: Calling .where('unknownAlias.col = :v'), .orderBy('col') with no main alias, or referencing a property path whose root alias was never created. Also when the alias name has a typo or uses a different case than the one registered.
Common situations: Typo in the alias prefix. Using a column-only path ('col') without a main alias. Copying a where clause from another query with different aliases. Case-sensitivity mistakes on alias names.
Related errors
- Cannot get entity metadata for the given alias "${this.name}
- Main alias is not set
- Entity where values should be inserted is not specified. Cal
- Unsupported FindOperator ${FindOperator.constructor.name}
- Cannot find alias for relation at ${fullRelationPath}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b1b84a547a7fe892.
Report an issue: GitHub.