JuliusBrussee/caveman · error

cave_input_too_large

cave_input_too_large

Error message

cave_input_too_large: stdin exceeds %d bytes

What it means

The CLI's bounded-input guard rejected stdin because it exceeded maxStdinBytes. Input is read through io.LimitReader(r, max+1); getting more than max bytes proves the limit was hit, so the run aborts before doing work. The error carries the code cave_input_too_large for machine handling.

Source

Thrown at engine/cmd/caveman-engine/main.go:239

		out, err = toonDecodeBytes(input)
	default:
		fatal("usage: caveman-engine toon encode|decode")
	}
	if err != nil {
		fatal("toon %s: %v", args[0], err)
	}
	if _, err := os.Stdout.Write(out); err != nil {
		fatal("write stdout: %v", err)
	}
}

func readBoundedInput(r io.Reader, maxBytes int64) ([]byte, error) {
	input, err := io.ReadAll(io.LimitReader(r, maxBytes+1))
	if err != nil {
		return nil, err
	}
	if int64(len(input)) > maxBytes {
		return nil, fmt.Errorf("cave_input_too_large: stdin exceeds %d bytes", maxBytes)
	}
	return input, nil
}

func runPixel(args []string) {
	if len(args) < 1 {
		pixelUsage()
		os.Exit(2)
	}
	switch args[0] {
	case "render":
		runPixelRender(args[1:])
	case "simulate":
		runPixelSimulate(args[1:])
	case "help", "--help", "-h":
		pixelUsage()
	default:
		fatal("usage: caveman-engine pixel render|simulate")

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Split the input into chunks at or under maxStdinBytes and process them separately.
  2. If your integration allows it, raise maxStdinBytes at CLI configuration/flag level and re-run.
  3. Pre-check the payload size in your wrapper script before invoking the engine.
  4. Compress or filter the input upstream if only a subset is relevant.

Example fix

# before
big.log | caveman-engine compress

# after: pre-check and split
split -b $((MAX-1)) big.log chunk. && for f in chunk.*; do caveman-engine compress < "$f"; done
Defensive patterns

Strategy: validation

Validate before calling

func sizeWithinLimit(path string, max int64) bool {
    fi, err := os.Stat(path)
    return err == nil && fi.Size() <= max
}

Try / catch

// Parse the exit output for the cave_input_too_large code and split the input
// rather than retrying the same oversized payload.

Prevention

When it happens

Trigger: Piping or redirecting a file larger than maxStdinBytes into any caveman-engine subcommand that reads stdin (compress, detect, etc.).

Common situations: Feeding a huge log, dataset, or concatenated corpus where the default cap is smaller; raising expectations after a version bump that lowered the cap; CI fixtures that grew past the limit.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/cd8c4ecab8594864. Report an issue: GitHub.