Budibase/budibase · error
Junction table '${relationship.junctionTable}' not found in
Error message
Junction table '${relationship.junctionTable}' not found in datasource What it means
After confirming junctionTable is set, createRelationshipColumns looks the junction table up in datasource.entities. If the named table does not exist in the datasource being imported, it throws this error. The check prevents generating relationship columns that reference a non-existent table.
Source
Thrown at packages/builder/src/components/backend/Datasources/TableImportSelection/relationshipSelectionStore.ts:179
) {
// Relationship already exists, skip creating it
return false
}
if (
relationship.relationshipType === DatasourceRelationshipType.MANY_TO_MANY
) {
// For many-to-many relationships, we need the junction table
if (!relationship.junctionTable) {
throw new Error(
`Junction table not specified for many-to-many relationship between ${relationship.sourceTable} and ${relationship.targetTable}`
)
}
// Get the junction table entity
const junctionTable = datasource.entities[relationship.junctionTable]
if (!junctionTable) {
throw new Error(
`Junction table '${relationship.junctionTable}' not found in datasource`
)
}
// Generate unique column names
const sourceColumnName = generateRelationshipColumnName(
sourceTable.schema,
relationship.targetTable,
relationship.sourceColumn
)
const targetColumnName = generateRelationshipColumnName(
targetTable.schema,
relationship.sourceTable,
relationship.targetColumn
)
// Create many-to-many relationship columnsView on GitHub (pinned to a81a902e9a)
Solutions
- Ensure the junction table is included in the import selection so it exists in datasource.entities.
- Fix relationship.junctionTable to exactly match a table name present in datasource.entities.
- Re-sync the datasource schema so the join table entity is present, then retry.
Example fix
// before
{ junctionTable: "UserRoles" } // table imported as "user_roles"
// after
{ junctionTable: "user_roles" } // must match datasource.entities key exactly Defensive patterns
Strategy: validation
Validate before calling
const missing = relationships
.filter(r => r.relationshipType === DatasourceRelationshipType.MANY_TO_MANY)
.filter(r => r.junctionTable && !datasource.entities[r.junctionTable])
if (missing.length) throw new Error(`Unknown junction tables: ${missing.map(r => r.junctionTable).join(", ")}`) Type guard
const junctionExists = (r: Relationship, ds: Datasource): r is Relationship & { junctionTable: string } =>
!!r.junctionTable && !!ds.entities[r.junctionTable] Try / catch
try {
await createRelationshipColumns(...)
} catch (e) {
if (e.message.startsWith("Junction table")) {
const name = e.message.match(/'([^']+)'/)?.[1]
console.warn(`Junction table ${name} missing; skipping relationship`); return
}
throw e
} Prevention
- Include the junction table in the tables selected for import.
- Match junctionTable names exactly against datasource.entities keys (case-sensitive).
- Re-fetch the datasource schema after DB renames so entity names stay current.
When it happens
Trigger: relationship.junctionTable is set (so error 80 passes) but datasource.entities[relationship.junctionTable] is undefined — the join table name in the relationship definition does not match any imported table's name (typo, renamed table, or table not selected for import).
Common situations: Typos in junctionTable names; the junction table was excluded from the selected tables during import; table renamed in the database after relationships were captured; case-sensitivity mismatch between DB name and entities key.
Related errors
- Junction table not specified for many-to-many relationship b
- Source table '${relationship.sourceTable}' not found in data
- Target table '${relationship.targetTable}' not found in data
- Unknown plugin type - check schema.json: ${schema.type}
- Cannot render an empty flow chain
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/f274ee308e1b6058.
Report an issue: GitHub.