{"record":{"id":"01adc307b7891a98","repo":"wavetermdev/waveterm","slug":"input-exceeds-maximum-file-size-of-d-bytes-01adc3","errorCode":null,"errorMessage":"input exceeds maximum file size of %d bytes","messagePattern":"input exceeds maximum file size of (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file.go","lineNumber":256,"sourceCode":"\treturn nil\n}\n\nfunc fileWriteRun(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\tlimitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)\n\tdata, err := io.ReadAll(limitReader)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading input: %w\", err)\n\t}\n\tif len(data) > MaxFileSize {\n\t\treturn fmt.Errorf(\"input exceeds maximum file size of %d bytes\", MaxFileSize)\n\t}\n\tfileData.Data64 = base64.StdEncoding.EncodeToString(data)\n\terr = wshclient.FileWriteCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"writing file: %w\", err)\n\t}\n\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}}","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file.go#L238-L274","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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).","solutions":["Split the input and write in chunks, or use file streaming (e.g. `wsh file stream` / stream-based write) instead of one-shot write.","Compress the data before writing if the compressed size fits within MaxFileSize.","Check the input size first (wc -c) and trim or filter before piping into wsh file write.","If legitimate files of this size are needed, raise MaxFileSize in a fork and redeploy both client and remote wsh."],"exampleFix":"// before\ncat huge-video.mp4 | wsh file write remote.mp4   # > MaxFileSize\n// after\ncat chunk.bin | wsh file write remote-part1.bin   # write in <= MaxFileSize chunks","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(inputPath)\nif err != nil {\n    return err\n}\nif fi.Size() > MaxFileSize {\n    return fmt.Errorf(\"input is %d bytes; exceeds %d limit — use streaming write\", fi.Size(), MaxFileSize)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"input exceeds maximum file size\") {\n    // fall back to a streaming/chunked write path instead of one-shot write\n    return ErrTooLarge\n}","preventionTips":["Check input size with `wc -c` before piping into `wsh file write`.","Use the streaming file APIs for large or binary payloads.","Compress payloads when the compressed size fits within MaxFileSize.","Never pipe unbounded producer output (curl, tail -f) directly into file write."],"tags":["go","wsh","file-write","size-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}