{"record":{"id":"cd8c4ecab8594864","repo":"JuliusBrussee/caveman","slug":"cave-input-too-large","errorCode":"cave_input_too_large","errorMessage":"cave_input_too_large: stdin exceeds %d bytes","messagePattern":"cave_input_too_large: stdin exceeds (.+?) bytes","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/cmd/caveman-engine/main.go","lineNumber":239,"sourceCode":"\t\tout, err = toonDecodeBytes(input)\n\tdefault:\n\t\tfatal(\"usage: caveman-engine toon encode|decode\")\n\t}\n\tif err != nil {\n\t\tfatal(\"toon %s: %v\", args[0], err)\n\t}\n\tif _, err := os.Stdout.Write(out); err != nil {\n\t\tfatal(\"write stdout: %v\", err)\n\t}\n}\n\nfunc readBoundedInput(r io.Reader, maxBytes int64) ([]byte, error) {\n\tinput, err := io.ReadAll(io.LimitReader(r, maxBytes+1))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif int64(len(input)) > maxBytes {\n\t\treturn nil, fmt.Errorf(\"cave_input_too_large: stdin exceeds %d bytes\", maxBytes)\n\t}\n\treturn input, nil\n}\n\nfunc runPixel(args []string) {\n\tif len(args) < 1 {\n\t\tpixelUsage()\n\t\tos.Exit(2)\n\t}\n\tswitch args[0] {\n\tcase \"render\":\n\t\trunPixelRender(args[1:])\n\tcase \"simulate\":\n\t\trunPixelSimulate(args[1:])\n\tcase \"help\", \"--help\", \"-h\":\n\t\tpixelUsage()\n\tdefault:\n\t\tfatal(\"usage: caveman-engine pixel render|simulate\")","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/engine/cmd/caveman-engine/main.go#L221-L257","documentation":"readBoundedInput reads stdin with a LimitReader of maxBytes+1 and rejects input larger than maxStdinBytes with the coded error \"cave_input_too_large: stdin exceeds %d bytes\". The engine reads inputs into memory, so oversized payloads are refused up front (error code cave_input_too_large) instead of risking OOM.","triggerScenarios":"runCompress, runDetect, or runTOON calls readBoundedInput(os.Stdin, maxStdinBytes) and the piped/redirected stdin length exceeds maxStdinBytes — detected because LimitReader yielded maxBytes+1 bytes.","commonSituations":"Piping a very large log or dataset into the compress/detect/TOON verbs; an upstream agent forwarding an unbounded document; misjudging the byte limit when batching many files into one stream.","solutions":["Split the input into chunks smaller than the engine's stdin limit and process each separately.","Compress or trim the payload upstream before invoking the engine.","Check the documented maxStdinBytes value and measure your input size (`wc -c`) before calling.","If you control deployment, raise the configured maxStdinBytes limit deliberately."],"exampleFix":"// before\ncat huge.json | caveman-engine compress\n// after\nsplit -b 1m huge.json chunk_\nfor f in chunk_*; do caveman-engine compress < \"$f\"; done","handlingStrategy":"validation","validationCode":"info, _ := os.Stdin.Stat()\nif info.Mode()&os.ModeCharDevice == 0 {\n    n, _ := io.Copy(io.Discard, io.TeeReader(os.Stdin, io.MultiWriter())) // pre-measure or use wc -c upstream\n}","typeGuard":null,"tryCatchPattern":"out, err := run(...)\nif err != nil && strings.Contains(err.Error(), \"cave_input_too_large\") {\n    return fmt.Errorf(\"split input below %d bytes and retry\", maxStdinBytes)\n}","preventionTips":["Measure input size (`wc -c`) before invoking the engine","Chunk large datasets before streaming to stdin","Document maxStdinBytes in your pipeline config"],"tags":["cli","input-size","limit"],"backgroundTag":"payload-too-large","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}