{"record":{"id":"02c6433bd3ec28ed","repo":"JuliusBrussee/caveman","slug":"cave-harness-request-invalid","errorCode":"cave_harness_request_invalid","errorMessage":"cave_harness_request_invalid","messagePattern":"cave_harness_request_invalid","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/adapters.ts","lineNumber":127,"sourceCode":"  return Object.freeze({\n    id,\n    version: identity.adapterVersion,\n    manifest,\n    contractSHA256,\n    async run(request: HarnessRequest): Promise<HarnessResult> {\n      const frozenRequest = snapshotRequest(request);\n      const prepared = prepareLockedHarnessExecution({\n        build: frozenRequest.build,\n        harness: id,\n        adapterVersion: identity.adapterVersion,\n        upstreamVersion: identity.upstreamVersion,\n        contextIR: frozenRequest.contextIR,\n        plan: frozenRequest.plan,\n      });\n      const { build, planSHA256, contextIRSHA256 } = prepared;\n      if (typeof frozenRequest.prompt !== \"string\" || frozenRequest.prompt.length === 0 ||\n          typeof frozenRequest.runID !== \"string\" || frozenRequest.runID.length === 0) {\n        throw new Error(\"cave_harness_request_invalid\");\n      }\n      if (isAborted(frozenRequest.signal)) throw new Error(\"cave_harness_aborted\");\n      validateTransformEvidence(frozenRequest, frozenRequest.plan);\n      const execution = snapshotExecution(await invoke(frozenRequest));\n      if (isAborted(frozenRequest.signal)) throw new Error(\"cave_harness_aborted\");\n      validateExecution(execution, frozenRequest.plan);\n      return {\n        terminal: execution.terminal,\n        text: execution.text,\n        provider: execution.provider,\n        model: execution.model,\n        inputTokens: execution.inputTokens,\n        outputTokens: execution.outputTokens,\n        cacheReadTokens: execution.cacheReadTokens,\n        cacheWriteTokens: execution.cacheWriteTokens,\n        reasoningTokens: execution.reasoningTokens,\n        totalTokens: execution.totalTokens,\n        costUsd: execution.costUsd,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/agent/src/adapters.ts#L109-L145","documentation":"The caveman-shrink CLI reads stdin through readBoundedInput, which uses io.LimitReader with maxStdinBytes+1 (32 MiB) and errors with code cave_input_too_large when the input exceeds that bound. The limit exists to prevent unbounded memory use when shrinking large documents. The error carries a stable code prefix so callers can match on cave_input_too_large.","triggerScenarios":"Piping a file or stream larger than 32 MiB into `caveman-shrink` on stdin (e.g. cat huge.json | caveman-shrink), since main.go:47 calls readBoundedInput(os.Stdin, maxStdinBytes) with maxStdinBytes = 32 << 20.","commonSituations":"Feeding a huge tool catalog, log dump, or model output to the shrinker; concatenating many documents into one stdin stream; a generating process looping and appending output until it crosses 32 MiB.","solutions":["Split the input into chunks under 32 MiB and shrink each chunk separately.","Pre-filter the document to only the sections you need (e.g. extract the tools array first) before piping.","If you control the build, raise maxStdinBytes in shrink/cmd/caveman-shrink/main.go:23 — but verify available memory first."],"exampleFix":"# before\ncat huge-dump.json | caveman-shrink\n\n# after\njq '{tools: .tools}' huge-dump.json | caveman-shrink\n# or split: split -b 16m huge-dump.json chunk. && for f in chunk.*; do caveman-shrink < \"$f\"; done","handlingStrategy":"validation","validationCode":"# shell: check size before piping\nf=huge.json\nmax=$((32 * 1024 * 1024))\nsize=$(stat -c%s \"$f\")\nif [ \"$size\" -gt \"$max\" ]; then\n  echo \"input $size exceeds $max bytes; splitting or filtering required\" >&2\n  jq '{tools: .tools}' \"$f\" | caveman-shrink\nelse\n  caveman-shrink < \"$f\"\nfi","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"cave_input_too_large\") {\n        // split input into <32 MiB chunks and retry each chunk separately\n    }\n}","preventionTips":["Measure input size with stat/wc -c before piping to the CLI.","Pre-filter documents to the needed substructure (e.g. jq '{tools}') instead of sending entire dumps.","Treat 32 MiB as a hard contract in pipeline scripts; add a size assertion in CI."],"tags":["cli","stdin","limits","input-size"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}