{"record":{"id":"2f355325c620773b","repo":"t8y2/dbx","slug":"zookeeper-frame-length-d-exceeds-maximum-d","errorCode":null,"errorMessage":"ZooKeeper frame length %d exceeds maximum %d","messagePattern":"ZooKeeper frame length (.+?) exceeds maximum (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/zookeeper/sasl.go","lineNumber":172,"sourceCode":"\theader := make([]byte, 4)\n\tif _, err := io.ReadFull(reader, header); err != nil {\n\t\treturn nil, err\n\t}\n\tlength := int(int32(binary.BigEndian.Uint32(header)))\n\tif length < 0 || length > zooKeeperMaximumFrameLen {\n\t\treturn nil, fmt.Errorf(\"ZooKeeper frame length %d is invalid\", length)\n\t}\n\tpayload := make([]byte, length+4)\n\tcopy(payload, header)\n\tif _, err := io.ReadFull(reader, payload[4:]); err != nil {\n\t\treturn nil, err\n\t}\n\treturn payload, nil\n}\n\nfunc writeZooKeeperFrame(writer io.Writer, payload []byte) error {\n\tif len(payload) > zooKeeperMaximumFrameLen {\n\t\treturn fmt.Errorf(\"ZooKeeper frame length %d exceeds maximum %d\", len(payload), zooKeeperMaximumFrameLen)\n\t}\n\theader := make([]byte, 4)\n\tbinary.BigEndian.PutUint32(header, uint32(len(payload)))\n\tif err := writeAll(writer, header); err != nil {\n\t\treturn err\n\t}\n\treturn writeAll(writer, payload)\n}\n\nfunc writeAll(writer io.Writer, payload []byte) error {\n\tfor len(payload) > 0 {\n\t\twritten, err := writer.Write(payload)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif written <= 0 {\n\t\t\treturn io.ErrShortWrite\n\t\t}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/zookeeper/sasl.go#L154-L190","documentation":"writeZooKeeperFrame refuses to write payloads larger than zooKeeperMaximumFrameLen, since ZooKeeper frames carry a 32-bit length and the client enforces an upper bound for safety. This error means the caller attempted to send an oversized SASL token or payload in a single frame.","triggerScenarios":"zooKeeperSASLRound (sending a SASL token) or an anonymous caller invokes writeZooKeeperFrame with len(payload) > zooKeeperMaximumFrameLen.","commonSituations":"Extremely large SASL tokens from unusual cipher/qop settings, application code batching huge payloads into one frame, or a misconfigured zooKeeperMaximumFrameLen interacting with large tokens.","solutions":["Reduce the payload size — split it across multiple protocol operations if the protocol allows.","Check why the SASL token is so large (unusually large credentials or cipher output) and normalize them.","If the workload legitimately needs larger frames, raise zooKeeperMaximumFrameLen consistently on both sides, respecting the server's jute.maxbuffer.","Log len(payload) at the call site to confirm the actual size against the configured maximum."],"exampleFix":"// before\nframe := make([]byte, 0, 10*1024*1024) // 10MB payload\nerr := writeZooKeeperFrame(w, frame)\n// after\nif len(frame) > zooKeeperMaximumFrameLen { /* chunk or reject before writing */ }\nerr := writeZooKeeperFrame(w, frame)","handlingStrategy":"validation","validationCode":"if len(payload) > zooKeeperMaximumFrameLen {\n\treturn fmt.Errorf(\"payload %d exceeds frame limit %d\", len(payload), zooKeeperMaximumFrameLen)\n}\nreturn writeZooKeeperFrame(writer, payload)","typeGuard":null,"tryCatchPattern":"if err := writeZooKeeperFrame(w, payload); err != nil {\n\tif strings.Contains(err.Error(), \"exceeds maximum\") {\n\t\treturn chunkOrCompressPayload(payload)\n\t}\n\treturn err\n}","preventionTips":["Check payload size before every frame write, not only inside the writer.","Keep application payloads well under zooKeeperMaximumFrameLen (e.g. < 1MB).","Align zooKeeperMaximumFrameLen with the server's jute.maxbuffer if large values are required."],"tags":["framing","protocol","zookeeper","validation"],"backgroundTag":"frame-length-exceeds-maximum","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}