wavetermdev/waveterm · error
append would exceed maximum file size of %d bytes
Error message
append would exceed maximum file size of %d bytes
What it means
The append loop checks that the accumulated buffer plus the newly read chunk stays within remainingSpace = MaxFileSize - info.Size. If the append would push the remote file past the 10MB cap, it fails with 'append would exceed maximum file size of %d bytes'. Unlike error 191 (file already full), this fires mid-stream when the incoming data is too large for the remaining capacity.
Source
Thrown at cmd/wsh/cmd/wshcmd-file.go:298
if info.Size >= MaxFileSize {
return fmt.Errorf("file already at maximum size (%d bytes)", MaxFileSize)
}
reader := bufio.NewReader(WrappedStdin)
var buf bytes.Buffer
remainingSpace := MaxFileSize - info.Size
for {
chunk := make([]byte, 8192)
n, err := reader.Read(chunk)
if err == io.EOF {
break
}
if err != nil {
return fmt.Errorf("reading input: %w", err)
}
if int64(buf.Len()+n) > remainingSpace {
return fmt.Errorf("append would exceed maximum file size of %d bytes", MaxFileSize)
}
buf.Write(chunk[:n])
if buf.Len() >= 8192 { // 8KB batch size
fileData.Data64 = base64.StdEncoding.EncodeToString(buf.Bytes())
err = wshclient.FileAppendCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
if err != nil {
return fmt.Errorf("appending to file: %w", err)
}
remainingSpace -= int64(buf.Len())
buf.Reset()
}
}
if buf.Len() > 0 {
fileData.Data64 = base64.StdEncoding.EncodeToString(buf.Bytes())
err = wshclient.FileAppendCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})View on GitHub (pinned to a4447c1563)
Solutions
- Pre-check the remote file size and truncate your input to fit the remaining space
- Rotate: append to a second file once the first approaches 10MB
- Write the whole payload to a fresh file with 'wsh file write' if combined size exceeds 10MB and old content is replaceable
Example fix
// before big-stream | wsh file append [block] out.bin # exceeds remaining space // after head -c 5000000 big-stream | wsh file append [block] out.bin # stay under the cap
Defensive patterns
Strategy: validation
Validate before calling
info, _ := wshclient.FileInfoCommand(RpcClient, wshrpc.CommandFileData{Info: &wshrpc.FileInfo{Path: path}}, &wshrpc.RpcOpts{Timeout: fileTimeout})
inputSize, _ := streamLen() // e.g. stat of temp input file
if info.Size+inputSize > 10*1024*1024 {
return fmt.Errorf("append of %d bytes would exceed cap (file at %d)", inputSize, info.Size)
} Type guard
func fitsInCap(current, incoming int64) bool {
return current+incoming <= 10*1024*1024
} Prevention
- Compute remaining space (10MB - current size) before appending
- Truncate or pre-split input to fit the remaining space
- Prefer a fresh 'wsh file write' when combined size exceeds 10MB
When it happens
Trigger: Piping more than (MaxFileSize - current file size) bytes into 'wsh file append'; the check triggers when buf.Len()+n exceeds remainingSpace, before any batch flush containing the excess.
Common situations: Appending a large log/dataset to a file that already holds several MB; long-running append jobs whose input grows past the cap; not realizing the 10MB cap applies to the resulting file, not the appended portion.
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
- file %s exceeds maximum size of %s for %s files
- file already at maximum size (%d bytes)
- Image too large (>5MB)
- input exceeds maximum file size of %d bytes
- file size (%d bytes) exceeds maximum of %d bytes
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/26af5ee03d08930c.
Report an issue: GitHub.