{"record":{"id":"d4ec4d8cafc4d617","repo":"Budibase/budibase","slug":"unable-to-connect","errorCode":null,"errorMessage":"Unable to connect","messagePattern":"Unable to connect","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/builder/src/stores/builder/datasources.ts","lineNumber":277,"sourceCode":"  async save({\n    integration,\n    datasource,\n    skipConnectionCheck,\n  }: {\n    integration: Integration\n    datasource: Datasource\n    skipConnectionCheck?: boolean\n  }) {\n    const existingDatasource = get(this.store).rawList.find(\n      existing => existing._id === datasource._id\n    )\n    const isRename =\n      !!existingDatasource && existingDatasource.name !== datasource.name\n    if (\n      !skipConnectionCheck &&\n      !(await this.checkDatasourceValidity(integration, datasource)).valid\n    ) {\n      throw new Error(\"Unable to connect\")\n    }\n\n    const response = await API.updateDatasource(datasource)\n    const updatedDatasource = this.updateDatasourceInStore(response)\n    if (isRename) {\n      try {\n        await Promise.all([\n          agentsStore.fetchAgents(),\n          workspaceDeploymentStore.fetch(),\n        ])\n      } catch (error) {\n        console.error(\"Failed to refresh agents after datasource rename\", error)\n      }\n    }\n    return updatedDatasource\n  }\n\n  async deleteDatasource(datasource: Datasource) {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/builder/src/stores/builder/datasources.ts#L259-L295","documentation":"datasources.save (update path) optionally re-validates connectivity unless skipConnectionCheck is set. If the check reports invalid it throws 'Unable to connect' (no detail appended here) and the datasource is not updated. This guards against persisting a broken connection config over a working one.","triggerScenarios":"Saving datasource edits (rename, config change) without skipConnectionCheck when the checkDatasourceValidity probe fails — same causes as creation but triggered on update; also occurs when merely renaming a datasource whose DB has meanwhile gone offline.","commonSituations":"Renaming a datasource while its database is temporarily unreachable; editing credentials with a typo; environment drift where prod DB is unreachable from the builder session.","solutions":["Fix the connection settings so the validity check passes, then save.","If only renaming and the DB is transiently down, wait for the DB to recover or pass skipConnectionCheck if the flow supports it.","Confirm reachability/credentials as in the create flow (host, port, auth, TLS)."],"exampleFix":"// before\nawait datasourceStore.save(datasource) // fails while DB is briefly down\n// after\nawait datasourceStore.save(datasource, { skipConnectionCheck: true }) // rename-only save","handlingStrategy":"try-catch","validationCode":"if (!skipConnectionCheck) {\n  const { valid, error } = await datasourceStore.checkDatasourceValidity(integration, datasource)\n  if (!valid) {\n    showConnectionErrorDialog(error)\n    return\n  }\n}","typeGuard":"const isConnectivityError = (e: unknown): e is Error =>\n  e instanceof Error && e.message === \"Unable to connect\"","tryCatchPattern":"try {\n  await datasourceStore.save(datasource)\n} catch (e) {\n  if (e instanceof Error && e.message === \"Unable to connect\") {\n    promptRetryOrForce({ onRetry: () => datasourceStore.save(datasource), onSkip: () => datasourceStore.save(datasource, { skipConnectionCheck: true }) })\n    return\n  }\n  throw e\n}","preventionTips":["Pass skipConnectionCheck for metadata-only saves like renames.","Check DB availability before editing datasources.","Surface the validity-check error detail to users before they hit save.","Retry saves after transient outages rather than assuming config is wrong."],"tags":["network","connectivity","datasources","validation"],"backgroundTag":"unable-to-connect","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}