{"record":{"id":"770f09923b9bcc2e","repo":"mastra-ai/mastra","slug":"worker-input-exceeds-inputlimitbytes-data-bytel","errorCode":null,"errorMessage":"Worker input exceeds inputLimitBytes (${data.byteLength} > ${config.inputLimitBytes}).","messagePattern":"Worker input exceeds inputLimitBytes \\((.+?) > (.+?)\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/worker.ts","lineNumber":428,"sourceCode":"  return {\n    ...execution(config, executionId, sandboxId, expiresAt),\n    relaunch: async options => {\n      if (options.executionId === executionId) throw new Error('Relaunch requires a new executionId.');\n      validateInput(options.input);\n      return createExecution(config, options.executionId, options.input);\n    },\n  };\n}\n\nasync function stageInput(\n  config: WorkerConfig,\n  paths: ReturnType<typeof executionPaths>,\n  input?: SandboxWorkerInput,\n): Promise<string | undefined> {\n  if (!input) return undefined;\n  const data = typeof input.data === 'string' ? Buffer.from(input.data) : Buffer.from(input.data);\n  if (data.byteLength > config.inputLimitBytes) {\n    throw new Error(`Worker input exceeds inputLimitBytes (${data.byteLength} > ${config.inputLimitBytes}).`);\n  }\n  const path = input.type === 'stdin' ? paths.stdin : posix.resolve(config.remoteDir, input.path);\n  await uploadFile(config.sandbox, path, data);\n  await runInSandbox(config.sandbox, `chmod 600 ${shellQuote(path)}`);\n  return input.type === 'stdin' ? path : undefined;\n}\n\nfunction buildExecutionScript(\n  config: WorkerConfig,\n  paths: ReturnType<typeof executionPaths>,\n  stdinPath?: string,\n): string {\n  const cwd = posix.resolve(config.remoteDir, config.workingDirectory);\n  const envPrefix = Object.entries(config.env)\n    .map(([key, value]) => `${key}=${shellQuote(value)}`)\n    .join(' ');\n  const executable = [shellQuote(config.command), ...config.args.map(shellQuote)].join(' ');\n  const target = `${envPrefix ? `env ${envPrefix} ` : ''}${executable}`;","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/worker.ts#L410-L446","documentation":"stageInput uploads worker input into the sandbox but enforces a configured maximum input size (config.inputLimitBytes). If the serialized input buffer is larger than that limit, the library throws before any upload, since oversized payloads could exhaust sandbox memory/disk or break the transport.","triggerScenarios":"Calling the worker deployment with input whose Buffer/string byteLength exceeds inputLimitBytes — via the stdinPath/stageInput path when preparing stdin input or a staged input file.","commonSituations":"Passing large JSON payloads, embeddings, or file blobs as worker input; inputLimitBytes configured too small for the workload; double-encoded (base64) input inflating byte size; forgetting to chunk large inputs.","solutions":["Increase config.inputLimitBytes to accommodate your payload size.","Split the input into chunks and pass a reference (e.g. an object-store key or path) instead of inlining the data.","Compress the payload before staging and decompress inside the worker.","Trim the input to only the data the worker actually needs."],"exampleFix":"// before\nawait worker.run({ input: { type: 'stdin', data: bigJsonString } });\n// after\nif (Buffer.byteLength(bigJsonString) > inputLimitBytes) {\n  await uploadToStore(key, bigJsonString);\n  await worker.run({ input: { type: 'stdin', data: JSON.stringify({ ref: key }) } });\n}","handlingStrategy":"validation","validationCode":"function assertInputWithinLimit(input, inputLimitBytes) {\n  const bytes = Buffer.byteLength(typeof input === 'string' ? input : input.data);\n  if (bytes > inputLimitBytes) throw new Error(`input ${bytes}B exceeds limit ${inputLimitBytes}B`);\n}","typeGuard":"function inputFitsLimit(input, limit) {\n  if (!input) return true;\n  const data = input.data;\n  const size = typeof data === 'string' ? Buffer.byteLength(data) : data?.byteLength ?? 0;\n  return size <= limit;\n}","tryCatchPattern":"try {\n  await worker.run({ input });\n} catch (e) {\n  if (/exceeds inputLimitBytes/.test(e.message)) {\n    // offload to external storage and pass a reference instead\n  } else throw e;\n}","preventionTips":["Check input byte size against inputLimitBytes before every call.","Prefer passing storage references over inlining large blobs.","Watch for base64/double encoding inflating payload size.","Set inputLimitBytes deliberately based on your workload, not the default."],"tags":["sandbox","validation","payload-size","input"],"backgroundTag":"payload-too-large","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}