{"record":{"id":"b2b3a86808aeeb84","repo":"wavetermdev/waveterm","slug":"input-data-too-large","errorCode":null,"errorMessage":"input data too large","messagePattern":"input data too large","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshutil.go","lineNumber":80,"sourceCode":"}\n\nfunc oscPrefixLen(oscNum string) int {\n\treturn 3 + len(oscNum)\n}\n\nfunc makeOscPrefix(oscNum string) []byte {\n\toutput := make([]byte, oscPrefixLen(oscNum))\n\tcopyOscPrefix(output, oscNum)\n\treturn output\n}\n\nfunc EncodeWaveOSCBytes(oscNum string, barr []byte) ([]byte, error) {\n\tif len(oscNum) != 5 {\n\t\treturn nil, fmt.Errorf(\"oscNum must be 5 characters\")\n\t}\n\tconst maxSize = 64 * 1024 * 1024 // 64 MB\n\tif len(barr) > maxSize {\n\t\treturn nil, fmt.Errorf(\"input data too large\")\n\t}\n\thasControlChars := false\n\tfor _, b := range barr {\n\t\tif b < 0x20 || b == 0x7F {\n\t\t\thasControlChars = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !hasControlChars {\n\t\t// If no control characters, directly construct the output\n\t\t// \\x1b] (2) + WaveOSC + ; (1) + message + \\x07 (1)\n\t\toutput := make([]byte, oscPrefixLen(oscNum)+len(barr)+1)\n\t\tcopyOscPrefix(output, oscNum)\n\t\tcopy(output[oscPrefixLen(oscNum):], barr)\n\t\toutput[len(output)-1] = BEL\n\t\treturn output, nil\n\t}\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshutil.go#L62-L98","documentation":"EncodeWaveOSCBytes enforces a hard 64 MB ceiling on the payload it will wrap in an OSC sequence, because terminals cannot reliably handle arbitrarily large escape sequences. Inputs larger than 64*1024*1024 bytes are rejected without attempting to encode.","triggerScenarios":"Calling EncodeWaveOSCBytes (directly or via AdaptMsgChToPty / EncodeWaveOSCMessageEx) with a []byte or JSON-marshalled RpcMessage whose length exceeds 64 MB.","commonSituations":"Sending a very large file's contents through the terminal OSC channel; an RpcMessage containing a huge base64 blob or oversized command output.","solutions":["Split the payload into chunks below 64 MB and send each separately.","Move bulk data through a file or separate data channel instead of the OSC stream.","Cap payload size at the producer before pushing to the channel.","Compress the data before sending if the receiving side supports it."],"exampleFix":"// before\nbarr, err := EncodeWaveOSCBytes(\"1337;\", hugeBlob)\n// after\nconst chunkMax = 32 * 1024 * 1024\nfor i := 0; i < len(hugeBlob); i += chunkMax {\n    end := min(i+chunkMax, len(hugeBlob))\n    barr, err := EncodeWaveOSCBytes(\"1337;\", hugeBlob[i:end])\n    if err != nil { return err }\n    if _, err := output.Write(barr); err != nil { return err }\n}","handlingStrategy":"validation","validationCode":"const oscMaxSize = 64 * 1024 * 1024\nif len(barr) > oscMaxSize {\n    return fmt.Errorf(\"payload %d bytes exceeds %d limit\", len(barr), oscMaxSize)\n}","typeGuard":null,"tryCatchPattern":"barr, err := EncodeWaveOSCBytes(oscNum, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"input data too large\") {\n        return chunkAndSend(data) // fallback path\n    }\n    return err\n}","preventionTips":["Enforce a producer-side size cap well below 64 MB","Chunk or stream large payloads through other channels","Add tests covering maximum-size payloads"],"tags":["go","limits","osc","payload-size"],"backgroundTag":"payload-too-large","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}