{"record":{"id":"0b28582302c0a787","repo":"t8y2/dbx","slug":"invalid-zookeeper-string-vector-length-d-0b2858","errorCode":null,"errorMessage":"invalid ZooKeeper string vector length %d","messagePattern":"invalid ZooKeeper string vector length (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/zookeeper_protocol.go","lineNumber":514,"sourceCode":"\t}\n\treturn append([]byte(nil), value...), nil\n}\n\nfunc (decoder *zooKeeperDecoder) string() (string, error) {\n\tvalue, err := decoder.bytes()\n\treturn string(value), err\n}\n\nfunc (decoder *zooKeeperDecoder) strings() ([]string, error) {\n\tlength, err := decoder.int32()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif length == -1 {\n\t\treturn nil, nil\n\t}\n\tif length < -1 || length > zooKeeperMaxFrameSize/4 {\n\t\treturn nil, fmt.Errorf(\"invalid ZooKeeper string vector length %d\", length)\n\t}\n\tvalues := make([]string, 0, length)\n\tfor index := int32(0); index < length; index++ {\n\t\tvalue, valueErr := decoder.string()\n\t\tif valueErr != nil {\n\t\t\treturn nil, valueErr\n\t\t}\n\t\tvalues = append(values, value)\n\t}\n\treturn values, nil\n}\n\nfunc (decoder *zooKeeperDecoder) stat() (*zk.Stat, error) {\n\tstat := &zk.Stat{}\n\tvar err error\n\tif stat.Czxid, err = decoder.int64(); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/zookeeper_protocol.go#L496-L532","documentation":"strings() decodes a ZooKeeper 'vector of strings' (used by getChildren). A length prefix of -1 is treated as a null vector (nil result); a negative length other than -1, or a length exceeding zooKeeperMaxFrameSize/4, is rejected with this error. It prevents absurd string-vector counts from driving huge allocations or long loops over a corrupted stream.","triggerScenarios":"Any Children() call where the response's vector length prefix is < -1 or above zooKeeperMaxFrameSize/4 — i.e. a corrupted/malformed getChildren reply or a desynchronized byte stream.","commonSituations":"Server or proxy truncating large getChildren replies (a directory with very many children), firewall/NAT mangling the TCP stream, protocol desync from an earlier failed read on the same connection, or connecting to a non-ZooKeeper endpoint.","solutions":["Reconnect the client to reset stream alignment; a single decode error usually means the whole connection is desynced.","Reduce the child count on the offending znode (archived old children, use a sharded layout) so replies stay well under the cap.","Check middleboxes (proxies, load balancers, NAT gateways) for response truncation; test from the same host as the server.","Confirm the endpoint is a real ZooKeeper server (four-letter 'srvr' command or nc to port 2181).","If legitimately huge listings are needed, raise zooKeeperMaxFrameSize/4's effective limit and redeploy with adequate memory."],"exampleFix":"// before\nchildren, err := client.Children(\"/tasks\") // 1M children -> reply exceeds cap\n// after\n// shard the znode so each getChildren reply is small\nchildren0, _ := client.Children(\"/tasks/shard-0\")\nchildren1, _ := client.Children(\"/tasks/shard-1\")","handlingStrategy":"validation","validationCode":"// keep directories small enough that getChildren replies stay tiny\nchildren, err := client.Children(parent)\nif err == nil && len(children) > 50000 {\n\tlog.Warnf(\"znode %s has %d children; consider sharding\", parent, len(children))\n}","typeGuard":"func isInvalidVectorLength(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"invalid ZooKeeper string vector length\")\n}","tryCatchPattern":"children, err := client.Children(path)\nif err != nil {\n\tif isInvalidVectorLength(err) {\n\t\tclient.Close()\n\t\tclient, err = hive.Dial(connStr) // desynced stream: reconnect\n\t\tif err == nil {\n\t\t\tchildren, err = client.Children(shardOf(path)) // retry smaller\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"zk children %s: %w\", path, err)\n\t}\n}","preventionTips":["Design znode layouts with bounded child counts (shard/partition instead of one huge directory).","Reconnect after any decode failure — the byte stream cannot be trusted afterwards.","Bypass proxies/NAT for ZooKeeper traffic or verify they don't truncate large responses.","Load-test with realistic directory sizes to confirm replies stay under the frame cap.","Verify endpoint identity (srvr/ruok) before blaming the data when this error appears on a new host."],"tags":["zookeeper","protocol-decode","vector-length","getchildren"],"backgroundTag":"invalid-decoder-length","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"}