{"record":{"id":"73a3d9195ab5b4f9","repo":"wavetermdev/waveterm","slug":"file-size-d-bytes-exceeds-maximum-of-d-bytes","errorCode":null,"errorMessage":"file size (%d bytes) exceeds maximum of %d bytes","messagePattern":"file size \\((.+?) bytes\\) exceeds maximum of (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file.go","lineNumber":342,"sourceCode":"\nfunc checkFileSize(path string, maxSize int64) (*wshrpc.FileInfo, error) {\n\tfileData := wshrpc.FileData{\n\t\tInfo: &wshrpc.FileInfo{\n\t\t\tPath: path}}\n\n\tinfo, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})\n\terr = convertNotFoundErr(err)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting file info: %w\", err)\n\t}\n\tif info.NotFound {\n\t\treturn nil, fmt.Errorf(\"%s: no such file\", path)\n\t}\n\tif info.IsDir {\n\t\treturn nil, fmt.Errorf(\"%s: is a directory\", path)\n\t}\n\tif info.Size > maxSize {\n\t\treturn nil, fmt.Errorf(\"file size (%d bytes) exceeds maximum of %d bytes\", info.Size, maxSize)\n\t}\n\treturn info, nil\n}\n\nfunc fileCpRun(cmd *cobra.Command, args []string) error {\n\tsrc, dst := args[0], args[1]\n\tmerge, err := cmd.Flags().GetBool(\"merge\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tforce, err := cmd.Flags().GetBool(\"force\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsrcPath, err := fixRelativePaths(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse src path: %w\", err)","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file.go#L324-L360","documentation":"checkFileSize enforces a per-command maximum (maxSize parameter) on source files for 'wsh file cp' and 'wsh file mv'; when info.Size exceeds it, the command fails with 'file size (%d bytes) exceeds maximum of %d bytes'. This protects the cp/mv transfer path from attempting to move files too large for the RPC-based transfer (distinct from the 10MB MaxFileSize used by write/append).","triggerScenarios":"'wsh file cp <src> <dst>' or 'wsh file mv <src> <dst>' where the remote source file's reported size (info.Size from FileInfoCommand) is greater than the maxSize passed by the calling command.","commonSituations":"Copying large datasets, videos, or build artifacts through wsh file cp; moving a file that grew since it was last handled; not knowing cp/mv impose their own size cap stricter/different from write's 10MB.","solutions":["Check the file size first ('wsh file info <src>') and pick a transfer method that supports it (scp/rsync, shared mount)","Split the file into chunks under the cap, cp each, and reassemble remotely","Compress the file to shrink it below the limit before copying"],"exampleFix":"// before\nwsh file cp [block] big-video.mp4 @   # 2GB: exceeds maximum\n// after\nsplit -b 500m big-video.mp4 part_ && for f in part_*; do wsh file cp [block] \"$f\" @; done  # then reassemble remotely","handlingStrategy":"validation","validationCode":"info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})\nif err == nil && info.Size > maxSize {\n    return fmt.Errorf(\"%s is %d bytes; cap is %d — use scp/rsync or split the file\", path, info.Size, maxSize)\n}","typeGuard":"func withinSizeLimit(info *wshrpc.FileInfo, maxSize int64) bool {\n    return info != nil && info.Size <= maxSize\n}","tryCatchPattern":null,"preventionTips":["Stat remote files before cp/mv and route oversized ones to scp/rsync or a shared mount","Split large files into chunks under the cap and reassemble remotely","Compress payloads to get under the limit before copying"],"tags":["file-size","limit","cp","mv"],"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"}