{"record":{"id":"23e2d912ba1ec76b","repo":"wavetermdev/waveterm","slug":"file-already-at-maximum-size-d-bytes","errorCode":null,"errorMessage":"file already at maximum size (%d bytes)","messagePattern":"file already at maximum size \\((.+?) bytes\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file.go","lineNumber":281,"sourceCode":"\n\treturn nil\n}\n\nfunc fileAppendRun(cmd *cobra.Command, args []string) error {\n\tpath, err := fixRelativePaths(args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\tfileData := wshrpc.FileData{\n\t\tInfo: &wshrpc.FileInfo{\n\t\t\tPath: path}}\n\n\tinfo, err := ensureFile(fileData)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif info.Size >= MaxFileSize {\n\t\treturn fmt.Errorf(\"file already at maximum size (%d bytes)\", MaxFileSize)\n\t}\n\n\treader := bufio.NewReader(WrappedStdin)\n\tvar buf bytes.Buffer\n\tremainingSpace := MaxFileSize - info.Size\n\tfor {\n\t\tchunk := make([]byte, 8192)\n\t\tn, err := reader.Read(chunk)\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading input: %w\", err)\n\t\t}\n\n\t\tif int64(buf.Len()+n) > remainingSpace {\n\t\t\treturn fmt.Errorf(\"append would exceed maximum file size of %d bytes\", MaxFileSize)\n\t\t}","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file.go#L263-L299","documentation":"wsh file append refuses to start when the remote file already has size >= MaxFileSize (10MB). The append command enforces the same hard cap as file write, so once a file reaches the cap no more data may be appended. The check uses FileInfo returned by ensureFile before any data is read from stdin.","triggerScenarios":"Running 'wsh file append [block] <path>' when ensureFile reports info.Size >= 10485760 bytes for the target file.","commonSituations":"Repeatedly appending log output to the same remote file until it hits the 10MB cap; piping an ongoing stream into an already-full file.","solutions":["Stop appending and rotate the file: write to a new file name instead","Truncate or remove the remote file if the old content is no longer needed ('wsh file write' with empty input or rm)","Split the data across multiple files under 10MB each"],"exampleFix":"// before\nwsh file append [block] app.log < stream.log   # fails: file already at maximum size\n// after\nwsh file write [block] app-2026-09.log < stream.log  # rotate to a new file","handlingStrategy":"validation","validationCode":"info, err := wshclient.FileInfoCommand(RpcClient, wshrpc.CommandFileData{Info: &wshrpc.FileInfo{Path: path}}, &wshrpc.RpcOpts{Timeout: fileTimeout})\nif err == nil && info.Size >= 10*1024*1024 {\n    return fmt.Errorf(\"cannot append: %s already at %d bytes\", path, info.Size)\n}","typeGuard":"func fileAtCap(info *wshrpc.FileInfo) bool {\n    return info != nil && info.Size >= 10*1024*1024\n}","tryCatchPattern":null,"preventionTips":["Check remote file size before long-running append jobs","Rotate log/data files before they reach 10MB","Monitor append targets with periodic 'wsh file info' calls"],"tags":["file-size","limit","append"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}