{"record":{"id":"a800ced295bf2792","repo":"mastra-ai/mastra","slug":"worker-command-must-be-a-non-empty-executable-path","errorCode":null,"errorMessage":"Worker command must be a non-empty executable path.","messagePattern":"Worker command must be a non-empty executable path\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/worker.ts","lineNumber":168,"sourceCode":"  let remoteDir: string | undefined;\n  const config: WorkerExecutionConfig = {\n    sandbox: options.sandbox,\n    resolveRemoteDir: async () => (remoteDir ??= await resolveRemoteDir(options.sandbox, options.remoteDir)),\n    terminationGraceMs: options.terminationGraceMs ?? 5_000,\n  };\n  const info = await getInfoSafe(options.sandbox);\n  return execution(config, options.executionId, info?.id ?? options.sandbox.id, info?.timeoutAt);\n}\n\nfunction validateOptions(options: DeployWorkerToSandboxOptions): void {\n  if (!options.sandbox.executeCommand) {\n    throw new Error(\n      `Sandbox provider \"${options.sandbox.provider}\" does not support executeCommand, which is required for worker deploys.`,\n    );\n  }\n  validateExecutionId(options.executionId);\n  if (!options.command || /[\\0\\r\\n]/.test(options.command)) {\n    throw new Error('Worker command must be a non-empty executable path.');\n  }\n  if (options.args?.some(arg => arg.includes('\\0'))) throw new Error('Worker arguments must not contain NUL bytes.');\n  for (const key of Object.keys(options.env ?? {})) {\n    if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`Invalid worker environment variable name: ${key}`);\n  }\n  validateRelativePath(options.workingDirectory ?? '.', 'workingDirectory');\n  validateInput(options.input);\n  for (const [name, value] of [\n    ['inputLimitBytes', options.inputLimitBytes],\n    ['startupTimeoutMs', options.startupTimeoutMs],\n    ['executionTimeoutMs', options.executionTimeoutMs],\n    ['terminationGraceMs', options.terminationGraceMs],\n  ] as const) {\n    if (value !== undefined && (!Number.isFinite(value) || value <= 0))\n      throw new Error(`${name} must be greater than zero.`);\n  }\n  const resourceLimits = options.resourceLimits;\n  if (resourceLimits) {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/worker.ts#L150-L186","documentation":"The worker `command` must be a non-empty executable path and is passed to the provider exec API as argv[0], so it must not contain NUL, CR, or LF characters. validateOptions rejects empty strings and control characters up front.","triggerScenarios":"Passing command: '' , command: undefined, or a command containing \\0, \\r, or \\n to deployWorkerToSandbox.","commonSituations":"Interpolating multi-line script text into `command` instead of using `args`; reading the command from an empty env var or config field; template strings that accidentally embed newlines.","solutions":["Pass a bare executable path in `command` (e.g. 'node', '/usr/local/bin/python') and put arguments in `args`.","Trim/validate the value at the config boundary before calling deployWorkerToSandbox.","For scripts, upload the script file and execute it via its path rather than inlining shell text."],"exampleFix":"// before\nawait deployWorkerToSandbox({ sandbox, command: 'node server.js\\n' });\n// after\nawait deployWorkerToSandbox({ sandbox, command: 'node', args: ['server.js'] });","handlingStrategy":"validation","validationCode":"if (!cmd || /[\\0\\r\\n]/.test(cmd)) throw new Error('Worker command must be a non-empty executable path without control characters');","typeGuard":"const isValidCommand = (v: unknown): v is string =>\n  typeof v === 'string' && v.length > 0 && !/[\\0\\r\\n]/.test(v);","tryCatchPattern":null,"preventionTips":["Keep command a bare executable path; move everything else into args","Never interpolate multi-line shell scripts into command","Trim config-sourced values and assert non-empty before deploy"],"tags":["worker","validation","configuration"],"backgroundTag":"invalid-option-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}