{"record":{"id":"6f3c727b8d5d02dc","repo":"Budibase/budibase","slug":"cannot-process-non-string-types","errorCode":null,"errorMessage":"Cannot process non-string types.","messagePattern":"Cannot process non-string types\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/string-templates/src/index.ts","lineNumber":214,"sourceCode":"function processStringSyncInternal(\n  str: string,\n  context?: object,\n  opts?: ProcessOptions & { logging: false }\n): string\nfunction processStringSyncInternal(\n  str: string,\n  context?: object,\n  opts?: ProcessOptions & { logging: true }\n): { result: string; logs: Log[] }\nfunction processStringSyncInternal(\n  string: string,\n  context?: object,\n  opts?: ProcessOptions & { logging: boolean }\n): string | { result: string; logs: Log[] } {\n  // Take a copy of input in case of error\n  const input = string\n  if (typeof string !== \"string\") {\n    throw new Error(\"Cannot process non-string types.\")\n  }\n  function process(stringPart: string) {\n    // context is needed to check for overlap between helpers and context\n    const template = createTemplate(stringPart, opts, context)\n    const now = Math.floor(Date.now() / 1000) * 1000\n    const processedString = template({\n      now: new Date(now).toISOString(),\n      __opts: {\n        ...opts,\n        input: stringPart,\n      },\n      ...context,\n    })\n    return opts?.logging\n      ? postprocessWithLogs(processedString)\n      : postprocess(processedString)\n  }\n  try {","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/string-templates/src/index.ts#L196-L232","documentation":"processStringSyncInternal in packages/string-templates/src/index.ts requires its first argument to be a string template. If anything else (null, undefined, a number, an object) is passed to processStringSync or processStringWithLogsSync, it throws \"Cannot process non-string types.\" immediately, before creating a copy of the input for error reporting.","triggerScenarios":"Calling processStringSync(undefined, ctx), passing a number or object instead of a template string, or piping a value that can be null (e.g. a missing automation/binding input) straight into the processor.","commonSituations":"Automations where a template field is empty/missing at runtime; REST/JS steps binding null request bodies into templates; TypeScript callers bypassing types with data from untyped JSON; refactors that changed a variable from string to optional.","solutions":["Check typeof template === \"string\" before calling, and substitute a default (e.g. \"\" or a placeholder).","Coerce known-safe values with String(value) when a string template is genuinely expected.","Make the template field required in your automation/step configuration so it can't be null.","Fix upstream data so the template input is populated."],"exampleFix":"// before\nconst out = processStringSync(automation.template, context)\n// after\nconst out = typeof automation.template === \"string\"\n  ? processStringSync(automation.template, context)\n  : \"\"","handlingStrategy":"type-guard","validationCode":"function safeProcess(template: unknown, ctx: object): string {\n  if (typeof template !== \"string\") return \"\"\n  return processStringSync(template, ctx)\n}","typeGuard":"function isTemplate(v: unknown): v is string {\n  return typeof v === \"string\"\n}","tryCatchPattern":"let out: string\ntry {\n  out = processStringSync(template, context)\n} catch (e) {\n  if (e.message === \"Cannot process non-string types.\") {\n    out = \"\"\n  } else throw e\n}","preventionTips":["Coerce or default template inputs (?? \"\") at boundaries where data may be null","Mark template fields as required in automation/step schemas","Type parameters as string so TypeScript catches undefined at compile time","Validate JSON-derived inputs before passing into string-templates"],"tags":["validation","typescript","handlebars","null-check"],"backgroundTag":"non-string-template-input","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}