{"record":{"id":"e599e1b3e0c09017","repo":"n8n-io/n8n","slug":"junction-property-is-not-defined","errorCode":null,"errorMessage":"Junction property is not defined.","messagePattern":"Junction property is not defined\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/query-builder/JoinAttribute.ts","lineNumber":222,"sourceCode":"            // and its target is a string name (scenario when plain old javascript is used or entity schema is loaded from files)\n            const metadata = this.connection.entityMetadatas.find(metadata => metadata.name === this.entityOrProperty);\n            if (metadata)\n                return metadata;\n\n            // check if we have entity with such table name, and use its metadata if found\n            return this.connection.entityMetadatas.find(metadata => metadata.tableName === this.entityOrProperty);\n        }*/\n\t}\n\n\t/**\n\t * Generates alias of junction table, whose ids we get.\n\t */\n\tget junctionAlias(): string {\n\t\tif (!this.relation) {\n\t\t\tthrow new TypeORMError(`Cannot get junction table for join without relation.`);\n\t\t}\n\t\tif (typeof this.entityOrProperty !== 'string') {\n\t\t\tthrow new TypeORMError(`Junction property is not defined.`);\n\t\t}\n\n\t\tconst aliasProperty = this.entityOrProperty.substr(0, this.entityOrProperty.indexOf('.'));\n\n\t\tif (this.relation.isOwning) {\n\t\t\treturn DriverUtils.buildAlias(\n\t\t\t\tthis.connection.driver,\n\t\t\t\tundefined,\n\t\t\t\taliasProperty,\n\t\t\t\tthis.alias.name,\n\t\t\t);\n\t\t} else {\n\t\t\treturn DriverUtils.buildAlias(\n\t\t\t\tthis.connection.driver,\n\t\t\t\tundefined,\n\t\t\t\tthis.alias.name,\n\t\t\t\taliasProperty,\n\t\t\t);","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/query-builder/JoinAttribute.ts#L204-L240","documentation":"JoinAttribute.junctionAlias getter, after confirming this.relation exists, throws if entityOrProperty is not a string. The junction alias is derived by splitting entityOrProperty on '.' (aliasProperty = entityOrProperty.substr(0, indexOf('.'))); a non-string target (entity class, subquery builder, or object) has no property string to derive the alias from.","triggerScenarios":"A JoinAttribute constructed with a non-string entityOrProperty (e.g. an entity class function or a SelectQueryBuilder) reaching the junctionAlias code path. This is typically an internal assertion failure rather than a direct API misuse.","commonSituations":"Passing an entity class reference instead of the string alias when constructing a many-to-many join. Internal TypeORM refactors that change entityOrProperty shape. Custom QueryBuilder extensions building JoinAttributes with object targets.","solutions":["Pass a string property path ('alias.relation') when the join needs junction alias derivation.","If using the public API, prefer leftJoin('alias.relation', 'joinAlias') string form for many-to-many joins.","Audit custom JoinAttribute construction to ensure entityOrProperty is a string for relation joins.","Report as an internal bug if it surfaces from plain repository/QueryBuilder usage."],"exampleFix":"// before — non-string join target in custom builder\nqb.innerJoin(userEntityClass, 'ue', 'ue.id = m.userId');\n\n// after — string property-path form\nqb.innerJoin('member.user', 'ue');","handlingStrategy":"validation","validationCode":"function isStringJoinTarget(t: unknown): t is string {\n  return typeof t === 'string' && t.includes('.');\n}\nif (!isStringJoinTarget(entityOrProperty)) throw new Error('join target must be a string property path \"alias.relation\" for relation joins');","typeGuard":"function isStringPropertyPath(t: unknown): t is string {\n  return typeof t === 'string' && /^[A-Za-z0-9_]+\\.[A-Za-z0-9_.]+$/.test(t);\n}","tryCatchPattern":null,"preventionTips":["Use string property-path form ('alias.relation') for relation joins.","Avoid passing entity classes or subquery builders where junction alias derivation is expected.","Audit custom JoinAttribute construction for non-string targets.","Treat this error as an internal bug if it arises from public API usage."],"tags":["query-builder","join","junction","internal"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}