{"record":{"id":"fb5b6449b436f5cb","repo":"wavetermdev/waveterm","slug":"size-must-be-greater-than-0-fb5b64","errorCode":null,"errorMessage":"size must be greater than 0","messagePattern":"size must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":841,"sourceCode":"\tvar fileInfoList []*wshrpc.WaveFileInfo\n\tfor _, wf := range fileList {\n\t\tfileInfoList = append(fileInfoList, waveFileToWaveFileInfo(wf))\n\t}\n\treturn &wshrpc.BlockInfoData{\n\t\tBlockId:     blockId,\n\t\tTabId:       tabId,\n\t\tWorkspaceId: workspaceId,\n\t\tBlock:       blockData,\n\t\tFiles:       fileInfoList,\n\t}, nil\n}\n\nfunc (ws *WshServer) DebugTermCommand(ctx context.Context, data wshrpc.CommandDebugTermData) (*wshrpc.CommandDebugTermRtnData, error) {\n\tif data.BlockId == \"\" {\n\t\treturn nil, fmt.Errorf(\"blockid is required\")\n\t}\n\tif data.Size <= 0 {\n\t\treturn nil, fmt.Errorf(\"size must be greater than 0\")\n\t}\n\twaveFile, err := filestore.WFS.Stat(ctx, data.BlockId, wavebase.BlockFile_Term)\n\tif err == fs.ErrNotExist {\n\t\treturn &wshrpc.CommandDebugTermRtnData{}, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error statting term file: %w\", err)\n\t}\n\treadSize := data.Size\n\tdataLength := waveFile.DataLength()\n\tif readSize > dataLength {\n\t\treadSize = dataLength\n\t}\n\treadOffset := waveFile.Size - readSize\n\treadOffset, readData, err := filestore.WFS.ReadAt(ctx, data.BlockId, wavebase.BlockFile_Term, readOffset, readSize)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading term file: %w\", err)\n\t}","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L823-L859","documentation":"Returned when a read request specifies a size that is not greater than zero.","triggerScenarios":"Calling DebugTermCommand with CommandDebugTermData.Size left at 0 or set to a negative value.","commonSituations":"Constructing the data struct without initializing Size (Go zero value); computing a size from an empty variable; typos passing the wrong field.","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"],"exampleFix":"// before\ndata := wshrpc.CommandDebugTermData{BlockId: blockId}\n// after\ndata := wshrpc.CommandDebugTermData{BlockId: blockId, Size: 4096}","handlingStrategy":"validation","validationCode":"if data.Size <= 0 {\n    return fmt.Errorf(\"cannot call DebugTermCommand: Size must be > 0\")\n}","typeGuard":"func validSize(data wshrpc.CommandDebugTermData) bool {\n    return data.Size > 0\n}","tryCatchPattern":"resp, err := client.DebugTermCommand(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"size must be greater than 0\") {\n        // fix payload: set Size > 0\n    }\n    return err\n}","preventionTips":["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"],"tags":["validation","rpc","wsh","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}