{"record":{"id":"8ac52eb799bb1648","repo":"Budibase/budibase","slug":"logging-disabled-for-backend-bindings","errorCode":null,"errorMessage":"Logging disabled for backend bindings","messagePattern":"Logging disabled for backend bindings","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/string-templates/src/index.ts","lineNumber":505,"sourceCode":"        })\n        .map(value => JSON.stringify(value))\n        .join(\" \")\n    } catch {\n      throw new Error(\"Multi-object JSON templates must be valid JSON objects\")\n    }\n  }\n}\n\n/**\n * Same as function above, but allows logging to be returned - this is only for JS bindings.\n */\nexport function processStringWithLogsSync(\n  string: string,\n  context?: object,\n  opts?: ProcessOptions\n): { result: string; logs: Log[] } {\n  if (isBackendService()) {\n    throw new Error(\"Logging disabled for backend bindings\")\n  }\n  return processStringSyncInternal(string, context, {\n    ...opts,\n    logging: true,\n  })\n}\n\n/**\n * By default with expressions like {{ name }} handlebars will escape various\n * characters, which can be problematic. To fix this we use the syntax {{{ name }}},\n * this function will find any double braces and switch to triple.\n * @param string the string to have double HBS statements converted to triple.\n */\nconst escapeRegExp = (value: string) =>\n  value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\nexport function disableEscaping(string: string) {\n  const matches = findDoubleHbsInstances(string)","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/string-templates/src/index.ts#L487-L523","documentation":"processStringWithLogsSync in packages/string-templates/src/index.ts returns binding logs alongside the rendered result. Logging is only supported in frontend/browser contexts; when isBackendService() is true (server/worker environments) it throws \"Logging disabled for backend bindings\" because backend template processing deliberately does not collect or emit logs.","triggerScenarios":"Calling processStringWithLogsSync (instead of processStringSync) from server-side code — e.g. automations, queries, or API steps running in the server/worker where the backend-service flag is active.","commonSituations":"Debugging automation bindings by switching to the *WithLogs variant in server code; shared code paths that use the logs variant unconditionally; tests simulating backend rendering with the logging API.","solutions":["Use processStringSync (no logs) in backend/server contexts.","Move the logging call to frontend code where binding logs are supported.","Gate the call: only use the WithLogs variant when not running as a backend service.","If you need visibility server-side, log inputs/outputs around processStringSync yourself."],"exampleFix":"// before\nconst { result, logs } = processStringWithLogsSync(template, ctx) // in server code\n// after\nconst result = processStringSync(template, ctx)","handlingStrategy":"try-catch","validationCode":"import { isBackendService } from \"@budibase/string-templates\"\n// only call the WithLogs variant in non-backend contexts\nconst useLogsVariant = !isBackendService()","typeGuard":null,"tryCatchPattern":"let result: string\nlet logs: Log[] = []\ntry {\n  const out = processStringWithLogsSync(template, ctx)\n  result = out.result\n  logs = out.logs\n} catch (e) {\n  if (e.message === \"Logging disabled for backend bindings\") {\n    result = processStringSync(template, ctx)\n  } else throw e\n}","preventionTips":["Use processStringWithLogsSync only in frontend/browser code","Default to processStringSync in shared/server code paths","Gate logging variants behind an isBackendService() check at the call site","If server-side visibility is needed, wrap processStringSync with your own logging"],"tags":["logging","environment","bindings","server-side"],"backgroundTag":"logging-disabled-backend","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}