{"record":{"id":"152dd349a09a7a3c","repo":"nanocoai/nanoclaw","slug":"stdin-json-input-exceeds-max-stdin-json-bytes","errorCode":null,"errorMessage":"--stdin-json input exceeds ${MAX_STDIN_JSON_BYTES} bytes","messagePattern":"--stdin-json input exceeds (.+?) bytes","errorType":"validation","errorClass":"StdinJsonInputError","httpStatus":null,"severity":"error","filePath":"container/agent-runner/src/cli/stdin-json.ts","lineNumber":54,"sourceCode":" * therefore normalized to a Buffer and the running total counts\n * `buffer.byteLength` — the true encoded size — rather than string length,\n * where a multibyte character (e.g. \"ש\", 2 bytes) would count as 1.\n *\n * Decoding to text happens exactly once, after the whole input is collected:\n * a chunk boundary can fall in the middle of a multibyte character, so\n * decoding chunk-by-chunk could corrupt the character that straddles the\n * split. The limit check runs before buffering grows past the cap, so an\n * oversized (or unbounded) pipe is rejected without being read to the end.\n */\nasync function readBounded(stream: StdinJsonStream): Promise<string> {\n  const chunks: Buffer[] = [];\n  let byteLength = 0;\n\n  for await (const chunk of stream) {\n    const buffer = typeof chunk === 'string' ? Buffer.from(chunk, 'utf8') : Buffer.from(chunk);\n    byteLength += buffer.byteLength;\n    if (byteLength > MAX_STDIN_JSON_BYTES) {\n      throw new StdinJsonInputError(`--stdin-json input exceeds ${MAX_STDIN_JSON_BYTES} bytes`);\n    }\n    chunks.push(buffer);\n  }\n\n  return Buffer.concat(chunks, byteLength).toString('utf8');\n}\n\n/** Parse the input, requiring exactly one JSON object — not an array, scalar, or null. */\nfunction parseJsonObject(source: string): Record<string, unknown> {\n  if (source.trim().length === 0) {\n    throw new StdinJsonInputError('--stdin-json input is empty');\n  }\n\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(source);\n  } catch (err) {\n    throw new StdinJsonInputError('--stdin-json input is not valid JSON', { cause: err });","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/container/agent-runner/src/cli/stdin-json.ts#L36-L72","documentation":"Thrown when the gateway provider composes auxiliary containers (e.g. a sidecar proxy) in the session spec, but the selected container driver does not declare the auxiliaryContainers capability. Composition checks this up front so the failure names the mismatched sides rather than surfacing later as a driver refusal backstop.","triggerScenarios":"spawnContainer() is called with a gateway provider that returns containers beyond the agent role (gateway.containers?.length > 0) while driver.capabilities().auxiliaryContainers is false (e.g. the docker driver).","commonSituations":"Switching an agent group to a gateway-based provider (needing a sidecar) while still using the default docker driver; upgrading to a provider that now composes auxiliary containers without updating the driver.","solutions":["Switch the session's driver to one that declares auxiliaryContainers in its capabilities()","Disable or reconfigure the gateway provider so it composes no auxiliary containers","If writing a custom driver, implement auxiliary container management and return auxiliaryContainers: true from capabilities()"],"exampleFix":"// before\nconst driver = getDriver('docker');\nawait spawnContainer({ agentGroup, gateway, driver }); // gateway composes sidecars\n\n// after\nconst driver = getDriver('gateway-aware'); // capabilities().auxiliaryContainers === true\nif (gateway.containers?.length && !driver.capabilities().auxiliaryContainers) throw new Error('pick another driver');\nawait spawnContainer({ agentGroup, gateway, driver });","handlingStrategy":"validation","validationCode":"if (gateway.containers?.length && !driver.capabilities().auxiliaryContainers) {\n  throw new Error(`driver '${driver.kind}' cannot manage gateway auxiliary containers`);\n}\nawait spawnContainer({ agentGroup, gateway, driver });","typeGuard":"function driverManagesAuxiliaries(d: Driver): boolean {\n  return d.capabilities().auxiliaryContainers === true;\n}","tryCatchPattern":null,"preventionTips":["Check driver.capabilities().auxiliaryContainers before wiring a gateway provider","Centralize driver selection in one factory so capability mismatches surface at config time"],"tags":["docker","driver-capabilities","auxiliary-containers","container-runner"],"backgroundTag":"driver-capability-mismatch","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}