{"record":{"id":"a73f21df1a6e2ede","repo":"Budibase/budibase","slug":"unable-to-find-table-named-tablename","errorCode":null,"errorMessage":"Unable to find table named \"${tableName}\"","messagePattern":"Unable to find table named \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/tables/getters.ts","lineNumber":209,"sourceCode":"    }\n\n    // filter out sample data here. i.e the sample ta_bb_employees gets included otherweise\n    final = final.filter(table => table._id && isExternalTableID(table._id))\n\n    span.addTags({ numTables: final.length })\n    return await processTables(final)\n  })\n}\n\nexport async function getExternalTable(\n  datasourceId: string,\n  tableName: string\n): Promise<Table> {\n  return await tracer.trace(\"getExternalTable\", async span => {\n    span.addTags({ datasourceId, tableName })\n    const entities = await getExternalTablesInDatasource(datasourceId)\n    if (!entities[tableName]) {\n      throw new Error(`Unable to find table named \"${tableName}\"`)\n    }\n    const table = await processTable(entities[tableName])\n    if (!table.sourceId) {\n      table.sourceId = datasourceId\n    }\n    return table\n  })\n}\n\nexport async function getTable(tableId: string): Promise<Table> {\n  return await tracer.trace(\"getTable\", async span => {\n    const db = context.getWorkspaceDB()\n    span.addTags({ tableId, db: db.name })\n    let output: Table\n    if (tableId && isExternalTableID(tableId)) {\n      let { datasourceId, tableName } = breakExternalTableId(tableId)\n      span.addTags({ isExternal: true, datasourceId, tableName })\n      const datasource = await datasources.get(datasourceId)","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/tables/getters.ts#L191-L227","documentation":"getExternalTable fetches a specific table by name from a datasource's fetched entities. If the datasource has no entity with that exact name, it throws with the requested tableName. This is a lookup failure against the live datasource metadata.","triggerScenarios":"Calling getExternalTable(datasourceId, tableName) (or tables.getExternalTable / get with a table name) where entities[tableName] is undefined — wrong name, table dropped, or case mismatch.","commonSituations":"Table renamed or dropped in the SQL database after last sync; case-sensitivity mismatch (Postgres lowercase vs quoted names); stale datasource entities cache; typo in table name.","solutions":["Verify the exact table name in the source database and re-request with the correct name","Refresh/sync the datasource entities so new tables are detected","Check case sensitivity (Postgres identifiers are lowercase unless quoted)","List available tables via getExternalTablesInDatasource(datasourceId) to find the right key"],"exampleFix":"// before\nawait tables.external.get(datasourceId, \"Users\") // table is actually \"users\"\n// after\nconst entities = await tables.external.getExternalTablesInDatasource(datasourceId)\nawait tables.external.get(datasourceId, Object.keys(entities).find(n => n.toLowerCase() === \"users\"))","handlingStrategy":"validation","validationCode":"const entities = await tables.external.getExternalTablesInDatasource(datasourceId)\nif (!entities[tableName]) throw new Error(`Unknown table: ${tableName}`)","typeGuard":"function tableExists(entities: Record<string, Table>, name: string): boolean {\n  return Object.prototype.hasOwnProperty.call(entities, name)\n}","tryCatchPattern":"try {\n  const t = await tables.external.get(datasourceId, tableName)\n} catch (err) {\n  if (err.message.startsWith(\"Unable to find table named\")) {\n    // refresh datasource entities or correct the table name\n  }\n}","preventionTips":["List entity names before lookups instead of hardcoding table names","Re-sync the datasource after renames/drops in the source DB","Match identifier casing exactly (esp. Postgres)"],"tags":["external-datasource","table-not-found","lookup"],"backgroundTag":"table-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}