{"record":{"id":"b2f1ca71f3ca5a94","repo":"AlexxIT/go2rtc","slug":"hds-write-buffer-too-big","errorCode":null,"errorMessage":"hds: write buffer too big","messagePattern":"hds: write buffer too big","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hap/hds/hds.go","lineNumber":126,"sourceCode":"\tfor {\n\t\tb, err := c.read()\n\t\tif err != nil {\n\t\t\treturn total, err\n\t\t}\n\n\t\tn, err := w.Write(b)\n\t\ttotal += int64(n)\n\t\tif err != nil {\n\t\t\treturn total, err\n\t\t}\n\t}\n}\n\nfunc (c *Conn) Write(b []byte) (n int, err error) {\n\tn = len(b)\n\n\tif n > 0xFFFFFF {\n\t\treturn 0, errors.New(\"hds: write buffer too big\")\n\t}\n\n\tverify := make([]byte, 4)\n\tbinary.BigEndian.PutUint32(verify, 0x01000000|uint32(n))\n\tif _, err = c.wr.Write(verify); err != nil {\n\t\treturn\n\t}\n\n\tnonce := make([]byte, hap.NonceSize)\n\tbinary.LittleEndian.PutUint64(nonce, c.encryptCnt)\n\tc.encryptCnt++\n\n\tbuf := make([]byte, n+hap.Overhead)\n\tif _, err = chacha20poly1305.EncryptAndSeal(c.encryptKey, buf[:0], nonce, b, verify); err != nil {\n\t\treturn\n\t}\n\n\tif _, err = c.wr.Write(buf); err != nil {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/hap/hds/hds.go#L108-L144","documentation":"HDS Write guard: the payload exceeds the protocol maximum of 0xFFFFFF bytes (the 3-byte length field in the frame header cannot represent it). The write is refused before any bytes hit the wire; the caller must split the data.","triggerScenarios":"Thrown at pkg/hap/hds/hds.go:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Chunk writes into blocks smaller than ~16MB","Stream data incrementally instead of building one huge buffer","Bound snapshot/media payloads upstream to fit HDS frame limits"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}