{"record":{"id":"1779597af2787148","repo":"Budibase/budibase","slug":"budibase-bash-automation-failed-args-must-be-a-js","errorCode":null,"errorMessage":"Budibase bash automation failed: Args must be a JSON array of strings.","messagePattern":"Budibase bash automation failed: Args must be a JSON array of strings\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/automations/steps/bash.ts","lineNumber":19,"sourceCode":"import execa from \"execa\"\nimport { findHBSBlocks, processStringSync } from \"@budibase/string-templates\"\nimport * as automationUtils from \"../automationUtils\"\nimport environment from \"../../environment\"\nimport { BashStepInputs, BashStepOutputs } from \"@budibase/types\"\n\nconst INVALID_INPUTS = \"Budibase bash automation failed: Invalid inputs\"\nconst COMMAND_BINDINGS_ERROR =\n  \"Budibase bash automation failed: Command bindings are not supported. Use the args field for dynamic values.\"\nconst ARGS_VALIDATION_ERROR =\n  \"Budibase bash automation failed: Args must be a JSON array of strings.\"\n\ninterface JsonEditorInput {\n  value?: unknown\n}\n\nconst validateArgs = (args: unknown): string[] => {\n  if (!Array.isArray(args) || args.some(arg => typeof arg !== \"string\")) {\n    throw new Error(ARGS_VALIDATION_ERROR)\n  }\n\n  return args\n}\n\nconst parseArgs = (args: unknown) => {\n  if (args == null) {\n    return []\n  }\n\n  if (Array.isArray(args)) {\n    return validateArgs(args)\n  }\n\n  if (typeof args === \"object\" && \"value\" in (args as JsonEditorInput)) {\n    const value = (args as JsonEditorInput).value\n\n    if (Array.isArray(value)) {","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/automations/steps/bash.ts#L1-L37","documentation":"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.","triggerScenarios":"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.","commonSituations":"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].","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."],"exampleFix":"// before\n{ \"step\": \"bash\", \"inputs\": { \"args\": \"-la /tmp\" } }\n// after\n{ \"step\": \"bash\", \"inputs\": { \"args\": [\"-la\", \"/tmp\"] } }","handlingStrategy":"validation","validationCode":"const isValidArgs = (args: unknown): args is string[] =>\n  Array.isArray(args) && args.every(a => typeof a === \"string\")\nif (!isValidArgs(inputs.args)) throw new Error(\"args must be a JSON array of strings\")","typeGuard":"const isStringArray = (v: unknown): v is string[] =>\n  Array.isArray(v) && v.every((x): x is string => typeof x === \"string\")","tryCatchPattern":"try {\n  await runBashStep({ args })\n} catch (err) {\n  if (err.message.includes(\"JSON array of strings\")) {\n    args = [String(args)].filter(Boolean)\n    return runBashStep({ args })\n  }\n  throw err\n}","preventionTips":["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."],"tags":["automation","validation","bash-step","input-validation"],"backgroundTag":"args-must-be-json-array-of-strings","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}