wavetermdev/waveterm · error

input exceeds maximum file size of %d bytes

Error message

input exceeds maximum file size of %d bytes

What it means

streamWriteToFile enforces MaxFileSize as a hard cap on streamed input. When the cumulative bytes read exceed the limit, it aborts with "input exceeds maximum file size of %d bytes" rather than shipping an oversized file over RPC.

Source

Thrown at cmd/wsh/cmd/wshcmd-file-util.go:76

	}

	const chunkSize = wshrpc.FileChunkSize // 32KB chunks
	buf := make([]byte, chunkSize)
	totalWritten := int64(0)

	for {
		n, err := reader.Read(buf)
		if err == io.EOF {
			break
		}
		if err != nil {
			return fmt.Errorf("reading input: %w", err)
		}

		// Check total size
		totalWritten += int64(n)
		if totalWritten > MaxFileSize {
			return fmt.Errorf("input exceeds maximum file size of %d bytes", MaxFileSize)
		}

		// Prepare and send chunk
		chunk := buf[:n]
		appendData := fileData
		appendData.Data64 = base64.StdEncoding.EncodeToString(chunk)

		err = wshclient.FileAppendCommand(RpcClient, appendData, &wshrpc.RpcOpts{Timeout: int64(fileTimeout)})
		if err != nil {
			return fmt.Errorf("appending chunk to file: %w", err)
		}
	}

	return nil
}

func streamReadFromFile(ctx context.Context, fileData wshrpc.FileData, writer io.Writer) error {
	broker := RpcClient.StreamBroker

View on GitHub (pinned to a4447c1563)

Solutions

  1. Check MaxFileSize (in the wsh cmd package) and verify your input's size with `ls -l` or `du` before streaming.
  2. Split or compress the input so it fits under the limit, then transfer in parts.
  3. Use scp/rsync/ssh directly for files larger than the cap.
  4. If the limit is too small for your workflow, rebuild wsh with an adjusted MaxFileSize constant (at your own risk).

Example fix

// before
cat 200GB.dump | wsh cp - remote:dump.bin
// after
split -b 90M 200GB.dump part_ && for f in part_*; do wsh cp "$f" "remote:dump_$f"; done
Defensive patterns

Strategy: validation

Validate before calling

fi, err := os.Stat(inputPath)
if err == nil && fi.Size() > MaxFileSize {
    return fmt.Errorf("input %s is %d bytes, exceeds limit %d", inputPath, fi.Size(), MaxFileSize)
}

Try / catch

if err := streamWriteToFile(fileData, reader); err != nil {
    if strings.Contains(err.Error(), "maximum file size") {
        // split/compress the input or use rsync/scp instead
    }
}

Prevention

When it happens

Trigger: Piping or copying input larger than MaxFileSize into `wsh` file streaming (e.g. `cat bigfile | wsh cp - remote:file`), where totalWritten > MaxFileSize after a chunk read.

Common situations: Redirecting huge log dumps, VM images, or datasets into wsh without checking size; underestimating binary sizes; accidentally piping an unbounded stream like `yes` or live logs.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/3a169400878ea019. Report an issue: GitHub.