{"record":{"id":"8aa5a309bb5603cc","repo":"Budibase/budibase","slug":"datasource-does-not-have-entities","errorCode":null,"errorMessage":"Datasource does not have entities","messagePattern":"Datasource does not have entities","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/server/src/api/controllers/row/ExternalRequest.ts","lineNumber":186,"sourceCode":"    operation: T,\n    source: Table | ViewV2,\n    opts: { datasource?: Datasource } = {}\n  ) {\n    if (!opts.datasource) {\n      if (sdk.views.isView(source)) {\n        const table = await sdk.views.getTable(source.id)\n        opts.datasource = await sdk.datasources.get(table.sourceId)\n      } else {\n        opts.datasource = await sdk.datasources.get(source.sourceId)\n      }\n    }\n\n    return new ExternalRequest(operation, source, opts.datasource)\n  }\n\n  private get tables(): { [key: string]: Table } {\n    if (!this.datasource.entities) {\n      throw new Error(\"Datasource does not have entities\")\n    }\n    return this.datasource.entities\n  }\n\n  private constructor(\n    operation: T,\n    source: Table | ViewV2,\n    datasource: Datasource\n  ) {\n    this.operation = operation\n    this.source = source\n    this.datasource = datasource\n  }\n\n  private prepareFilters(\n    id: string | undefined | string[],\n    filters: SearchFilters,\n    table: Table","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/row/ExternalRequest.ts#L168-L204","documentation":"ExternalRequest wraps all row operations against non-internal (SQL/REST/etc.) datasources. Its private tables getter throws this plain Error when the linked datasource document has no entities — i.e. the datasource was fetched/linked but never had its schema (tables) populated or fetched.","triggerScenarios":"Performing row operations via ExternalRequest when opts.datasource.entities is undefined/null — typically a datasource document loaded without running its schema fetch, or a datasource that failed to return entities.","commonSituations":"Datasources created but never 'fetched' in the builder so entities were never saved; datasource linkage pointing at an empty/degenerate document; custom code paths constructing ExternalRequest with a partial datasource object.","solutions":["Fetch the datasource schema (run the datasource fetch/sync) so entities are populated before row operations","Verify the datasource document is complete and linked correctly (check datasource.entities exists before constructing ExternalRequest)","Re-create or re-link the datasource if its schema is empty in the builder","Retry the row operation after the datasource schema sync completes"],"exampleFix":"// before\nconst req = new ExternalRequest(op, source, { datasource }) // entities undefined\n// after\nconst fetched = await datasourceFetchSchema(datasource)\nif (!fetched.entities) throw new Error(\"Datasource schema must be fetched first\")\nconst req = new ExternalRequest(op, source, { datasource: fetched })","handlingStrategy":"type-guard","validationCode":"if (!datasource?.entities || Object.keys(datasource.entities).length === 0) {\n  throw new Error(\"Datasource schema must be fetched before row operations\")\n}","typeGuard":"const hasEntities = (\n  d: unknown\n): d is { entities: Record<string, Table> } =>\n  typeof d === \"object\" && d !== null &&\n  \"entities\" in d && typeof (d as { entities: unknown }).entities === \"object\" &&\n  (d as { entities: unknown }).entities !== null","tryCatchPattern":"try {\n  return new ExternalRequest(operation, source, { datasource })\n} catch (e) {\n  if (/does not have entities/.test(e?.message)) {\n    // trigger datasource schema fetch then retry\n  } else throw e\n}","preventionTips":["Always run the datasource schema fetch/sync before row operations","Check datasource.entities is populated when linking datasources programmatically","Re-create datasources that show no tables in the builder"],"tags":["datasource","schema","external-request","missing-data"],"backgroundTag":"missing-datasource-entities","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}