wavetermdev/waveterm · error

input exceeds maximum file size of %d bytes

Error message

input exceeds maximum file size of %d bytes

What it means

fileWriteRun intentionally limits stdin reads to MaxFileSize+1 bytes; if more data is present, the input exceeds the RPC payload limit and the CLI aborts with this message before attempting the remote write.

Source

Thrown at cmd/wsh/cmd/wshcmd-file.go:256

	return nil
}

func fileWriteRun(cmd *cobra.Command, args []string) error {
	path, err := fixRelativePaths(args[0])
	if err != nil {
		return err
	}
	fileData := wshrpc.FileData{
		Info: &wshrpc.FileInfo{
			Path: path}}

	limitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)
	data, err := io.ReadAll(limitReader)
	if err != nil {
		return fmt.Errorf("reading input: %w", err)
	}
	if len(data) > MaxFileSize {
		return fmt.Errorf("input exceeds maximum file size of %d bytes", MaxFileSize)
	}
	fileData.Data64 = base64.StdEncoding.EncodeToString(data)
	err = wshclient.FileWriteCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
	if err != nil {
		return fmt.Errorf("writing file: %w", err)
	}

	return nil
}

func fileAppendRun(cmd *cobra.Command, args []string) error {
	path, err := fixRelativePaths(args[0])
	if err != nil {
		return err
	}
	fileData := wshrpc.FileData{
		Info: &wshrpc.FileInfo{
			Path: path}}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Split the input and write in chunks, or use file streaming (e.g. `wsh file stream` / stream-based write) instead of one-shot write.
  2. Compress the data before writing if the compressed size fits within MaxFileSize.
  3. Check the input size first (wc -c) and trim or filter before piping into wsh file write.
  4. If legitimate files of this size are needed, raise MaxFileSize in a fork and redeploy both client and remote wsh.

Example fix

// before
cat huge-video.mp4 | wsh file write remote.mp4   # > MaxFileSize
// after
cat chunk.bin | wsh file write remote-part1.bin   # write in <= MaxFileSize chunks
Defensive patterns

Strategy: validation

Validate before calling

fi, err := os.Stat(inputPath)
if err != nil {
    return err
}
if fi.Size() > MaxFileSize {
    return fmt.Errorf("input is %d bytes; exceeds %d limit — use streaming write", fi.Size(), MaxFileSize)
}

Try / catch

if strings.Contains(err.Error(), "input exceeds maximum file size") {
    // fall back to a streaming/chunked write path instead of one-shot write
    return ErrTooLarge
}

Prevention

When it happens

Trigger: `wsh file write <path>` with stdin data larger than MaxFileSize bytes: catting a huge log into the command, piping a binary such as a video or database dump, a producer that streams indefinitely.

Common situations: Trying to push large files through wsh file write instead of streaming alternatives, forgetting that the entire stdin content is base64-encoded into one RPC message, automation scripts piping unbounded output (e.g. curl to stdout).

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/01adc307b7891a98. Report an issue: GitHub.