Budibase/budibase · error · Error
Budibase bash automation failed: Args must be a JSON array o
Error message
Budibase bash automation failed: Args must be a JSON array of strings.
What it means
The Bash automation step validates its `args` input through `validateArgs`, which requires the value to be an array whose every element is a string. If args is not an array at all, or contains a non-string element (number, object, boolean), it throws ARGS_VALIDATION_ERROR, surfaced as 'Args must be a JSON array of strings'. This guards against injecting malformed argv into the spawned bash process.
Source
Thrown at packages/server/src/automations/steps/bash.ts:19
import execa from "execa"
import { findHBSBlocks, processStringSync } from "@budibase/string-templates"
import * as automationUtils from "../automationUtils"
import environment from "../../environment"
import { BashStepInputs, BashStepOutputs } from "@budibase/types"
const INVALID_INPUTS = "Budibase bash automation failed: Invalid inputs"
const COMMAND_BINDINGS_ERROR =
"Budibase bash automation failed: Command bindings are not supported. Use the args field for dynamic values."
const ARGS_VALIDATION_ERROR =
"Budibase bash automation failed: Args must be a JSON array of strings."
interface JsonEditorInput {
value?: unknown
}
const validateArgs = (args: unknown): string[] => {
if (!Array.isArray(args) || args.some(arg => typeof arg !== "string")) {
throw new Error(ARGS_VALIDATION_ERROR)
}
return args
}
const parseArgs = (args: unknown) => {
if (args == null) {
return []
}
if (Array.isArray(args)) {
return validateArgs(args)
}
if (typeof args === "object" && "value" in (args as JsonEditorInput)) {
const value = (args as JsonEditorInput).value
if (Array.isArray(value)) {View on GitHub (pinned to a81a902e9a)
Solutions
- Change args to a JSON array of strings, e.g. ["-la", "/tmp"] instead of "-la /tmp" or ["-la", 123].
- If args come from a previous step, wrap the value in a JS/string-template step that coerces each element with String(...) before passing it on.
- If the value is a JSON string like '["-la"]', note parseArgs already JSON.parses strings, so the JSON itself must parse to a string array; fix the inner JSON, not the quoting.
Example fix
// before
{ "step": "bash", "inputs": { "args": "-la /tmp" } }
// after
{ "step": "bash", "inputs": { "args": ["-la", "/tmp"] } } Defensive patterns
Strategy: validation
Validate before calling
const isValidArgs = (args: unknown): args is string[] =>
Array.isArray(args) && args.every(a => typeof a === "string")
if (!isValidArgs(inputs.args)) throw new Error("args must be a JSON array of strings") Type guard
const isStringArray = (v: unknown): v is string[] => Array.isArray(v) && v.every((x): x is string => typeof x === "string")
Try / catch
try {
await runBashStep({ args })
} catch (err) {
if (err.message.includes("JSON array of strings")) {
args = [String(args)].filter(Boolean)
return runBashStep({ args })
}
throw err
} Prevention
- Always pass args as a JSON array literal even for one argument.
- Quote numbers and booleans inside the array.
- Validate upstream step outputs before binding them to args.
When it happens
Trigger: Calling the bash step with `args` set to a plain string, a JSON object, null, or an array containing non-string items (e.g. [1,2] or ["ls", {"flag":true}]) passes the first Array.isArray/typeof check as false and throws.
Common situations: Configuring the step in the UI with a comma-separated string like 'ls, -la' instead of a JSON array; binding args from an automation context where a previous step returned a single string or numbers; hand-editing the automation definition JSON and using ["echo", 123].
Related errors
- Automation ID is required to test a saved password
- No trigger found for automation
- IMAP password is required when connection details change
- Template name is required
- Template description is required
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/1779597af2787148.
Report an issue: GitHub.