Budibase/budibase · error
Target table '${relationship.targetTable}' not found in data
Error message
Target table '${relationship.targetTable}' not found in datasource What it means
Same validation as the source table check, but for the relationship's target table: createRelationshipColumns requires datasource.entities[relationship.targetTable] to exist before it can build the join columns on both sides. Thrown when the referenced target table is missing from the datasource metadata.
Source
Thrown at packages/builder/src/components/backend/Datasources/TableImportSelection/relationshipSelectionStore.ts:140
return keepOpen
}
}
const createRelationshipColumns = async (
datasource: Datasource,
relationship: DatasourceRelationshipConfig
): Promise<boolean> => {
// Ensure the tables exist in the datasource
if (!datasource.entities) {
datasource.entities = {}
}
if (!datasource.entities[relationship.sourceTable]) {
throw new Error(
`Source table '${relationship.sourceTable}' not found in datasource`
)
}
if (!datasource.entities[relationship.targetTable]) {
throw new Error(
`Target table '${relationship.targetTable}' not found in datasource`
)
}
const sourceTable = datasource.entities[relationship.sourceTable]
const targetTable = datasource.entities[relationship.targetTable]
// Check if this relationship already exists
const junctionTableId =
relationship.relationshipType ===
DatasourceRelationshipType.MANY_TO_MANY && relationship.junctionTable
? datasource.entities[relationship.junctionTable]?._id
: undefined
if (
relationshipExists(
sourceTable,
targetTable,
relationship,View on GitHub (pinned to a81a902e9a)
Solutions
- Re-fetch/sync the datasource schema so the target table appears in datasource.entities.
- Correct relationship.targetTable to the table's current exact name (verify casing against entities keys).
- Recreate the relationship if the target table no longer exists in the external database.
Example fix
// before relationship.targetTable = "Customers" // dropped and recreated as "customer" // after relationship.targetTable = "customer" // current name in datasource.entities
Defensive patterns
Strategy: validation
Validate before calling
const assertTablesExist = (ds: Datasource, rel: { sourceTable: string; targetTable: string }) => {
if (!ds.entities?.[rel.targetTable]) {
throw new Error(`Target table '${rel.targetTable}' missing; refresh datasource schema`)
}
}
assertTablesExist(datasource, relationship) Type guard
const hasEntity = (ds: Datasource, table: string): ds is Datasource & { entities: Record<typeof table, Table> } =>
ds.entities != null && table in ds.entities Try / catch
try {
await store.wasCreated(datasource, relationship)
} catch (err) {
if (err instanceof Error && err.message.includes("Target table")) {
await refreshDatasourceSchema(datasource)
// verify target table exists or prompt user to re-select it
} else throw err
} Prevention
- Always fetch fresh entities before validating relationships, never trust cached metadata.
- Compare names case-sensitively against Object.keys(datasource.entities).
- Detect external schema drift periodically and flag broken relationships.
When it happens
Trigger: wasCreated → createRelationshipColumns called with a relationship whose relationship.targetTable key is absent from datasource.entities — target table dropped/renamed externally, entities not fetched, or name/casing mismatch in the stored relationship.
Common situations: External database schema changed (target table renamed or deleted) after the relationship was configured in Budibase; partial schema sync leaving entities incomplete; typo in the table name when relationships are defined programmatically or via older configs.
Related errors
- Source table '${relationship.sourceTable}' not found in data
- Junction table not specified for many-to-many relationship b
- Junction table '${relationship.junctionTable}' not found in
- Invalid custom REST template
- automationId and appId are required
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/5ebb22ad5687567c.
Report an issue: GitHub.