wavetermdev/waveterm · error
size must be greater than 0
Error message
size must be greater than 0
What it means
Returned when a read request specifies a size that is not greater than zero.
Source
Thrown at pkg/wshrpc/wshserver/wshserver.go:841
var fileInfoList []*wshrpc.WaveFileInfo
for _, wf := range fileList {
fileInfoList = append(fileInfoList, waveFileToWaveFileInfo(wf))
}
return &wshrpc.BlockInfoData{
BlockId: blockId,
TabId: tabId,
WorkspaceId: workspaceId,
Block: blockData,
Files: fileInfoList,
}, nil
}
func (ws *WshServer) DebugTermCommand(ctx context.Context, data wshrpc.CommandDebugTermData) (*wshrpc.CommandDebugTermRtnData, error) {
if data.BlockId == "" {
return nil, fmt.Errorf("blockid is required")
}
if data.Size <= 0 {
return nil, fmt.Errorf("size must be greater than 0")
}
waveFile, err := filestore.WFS.Stat(ctx, data.BlockId, wavebase.BlockFile_Term)
if err == fs.ErrNotExist {
return &wshrpc.CommandDebugTermRtnData{}, nil
}
if err != nil {
return nil, fmt.Errorf("error statting term file: %w", err)
}
readSize := data.Size
dataLength := waveFile.DataLength()
if readSize > dataLength {
readSize = dataLength
}
readOffset := waveFile.Size - readSize
readOffset, readData, err := filestore.WFS.ReadAt(ctx, data.BlockId, wavebase.BlockFile_Term, readOffset, readSize)
if err != nil {
return nil, fmt.Errorf("error reading term file: %w", err)
}View on GitHub (pinned to a4447c1563)
Solutions
- Set Size to a positive byte count (e.g. 1024 or 4096) before the RPC call
- If you want the whole file, still pass a positive size — the command clamps readSize to the file's actual data length
- Check upstream logic that computes Size for accidental zero/negative results
Example fix
// before
data := wshrpc.CommandDebugTermData{BlockId: blockId}
// after
data := wshrpc.CommandDebugTermData{BlockId: blockId, Size: 4096} Defensive patterns
Strategy: validation
Validate before calling
if data.Size <= 0 {
return fmt.Errorf("cannot call DebugTermCommand: Size must be > 0")
} Type guard
func validSize(data wshrpc.CommandDebugTermData) bool {
return data.Size > 0
} Try / catch
resp, err := client.DebugTermCommand(ctx, data)
if err != nil {
if strings.Contains(err.Error(), "size must be greater than 0") {
// fix payload: set Size > 0
}
return err
} Prevention
- Initialize Size explicitly, never rely on zero values
- Clamp computed sizes to a minimum of 1
- Remember the command clamps oversize reads, so a generous positive size is safe
When it happens
Trigger: Calling DebugTermCommand with CommandDebugTermData.Size left at 0 or set to a negative value.
Common situations: Constructing the data struct without initializing Size (Go zero value); computing a size from an empty variable; typos passing the wrong field.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- blockid is required
- invalid context, must have a routeid
- request packets may not have both reqid and resid set
- cancel packets may not have command set
- cancel packets must have reqid or resid set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/fb5b6449b436f5cb.
Report an issue: GitHub.