Budibase/budibase · error

Cannot process non-string types.

Error message

Cannot process non-string types.

What it means

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.

Source

Thrown at packages/string-templates/src/index.ts:214

function processStringSyncInternal(
  str: string,
  context?: object,
  opts?: ProcessOptions & { logging: false }
): string
function processStringSyncInternal(
  str: string,
  context?: object,
  opts?: ProcessOptions & { logging: true }
): { result: string; logs: Log[] }
function processStringSyncInternal(
  string: string,
  context?: object,
  opts?: ProcessOptions & { logging: boolean }
): string | { result: string; logs: Log[] } {
  // Take a copy of input in case of error
  const input = string
  if (typeof string !== "string") {
    throw new Error("Cannot process non-string types.")
  }
  function process(stringPart: string) {
    // context is needed to check for overlap between helpers and context
    const template = createTemplate(stringPart, opts, context)
    const now = Math.floor(Date.now() / 1000) * 1000
    const processedString = template({
      now: new Date(now).toISOString(),
      __opts: {
        ...opts,
        input: stringPart,
      },
      ...context,
    })
    return opts?.logging
      ? postprocessWithLogs(processedString)
      : postprocess(processedString)
  }
  try {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Check typeof template === "string" before calling, and substitute a default (e.g. "" or a placeholder).
  2. Coerce known-safe values with String(value) when a string template is genuinely expected.
  3. Make the template field required in your automation/step configuration so it can't be null.
  4. Fix upstream data so the template input is populated.

Example fix

// before
const out = processStringSync(automation.template, context)
// after
const out = typeof automation.template === "string"
  ? processStringSync(automation.template, context)
  : ""
Defensive patterns

Strategy: type-guard

Validate before calling

function safeProcess(template: unknown, ctx: object): string {
  if (typeof template !== "string") return ""
  return processStringSync(template, ctx)
}

Type guard

function isTemplate(v: unknown): v is string {
  return typeof v === "string"
}

Try / catch

let out: string
try {
  out = processStringSync(template, context)
} catch (e) {
  if (e.message === "Cannot process non-string types.") {
    out = ""
  } else throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/6f3c727b8d5d02dc. Report an issue: GitHub.