{"record":{"id":"c5749aa82d0ed907","repo":"t8y2/dbx","slug":"invalid-zookeeper-string-vector-length-d","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/argo-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/argo-go/zookeeper_protocol.go#L496-L532","documentation":"When decoding a string vector (e.g. the children list returned by a getChildren reply), the vector's element count must be either -1 (NULL) or a bounded positive number (at most zooKeeperMaxFrameSize/4). Any other value — negative or implausibly large — indicates a corrupt or misaligned stream, so decoder.strings refuses to preallocate and iterate over it.","triggerScenarios":"Calling Children (getChildren) when the reply's count field is garbage: reading a desynchronized stream after an earlier failed request, connecting to a non-ZooKeeper service, or frame bytes altered in transit so the count int32 reads as a huge or negative number.","commonSituations":"A directory node with a corrupted/oversized children list being read after a proxy mangled the response; sharing one client connection across goroutines so responses interleave; a port-forward or service mesh returning an error page parsed as a vector length.","solutions":["Close and re-dial the client connection; the stream is misaligned and subsequent reads on the same socket will also fail.","Verify the connection targets a genuine ZooKeeper server and that no TLS/proxy layer is transforming the bytes.","Avoid sharing the client (and its underlying connection) across concurrent goroutines without synchronization; interleaved reads shift the framing.","If the node legitimately has an enormous number of children, paginate by structuring children under nested parent znodes instead of one flat list."],"exampleFix":"// before\nchildren, _, err := zkClient.Children(\"/jobs\") // connection shared unsafely\n\n// after\nclient.mu.Lock()\nchildren, _, err := zkClient.Children(\"/jobs\")\nclient.mu.Unlock()\nif err != nil {\n    client.reconnect() // discard misaligned stream\n    return err\n}","handlingStrategy":"retry","validationCode":"// sanity-check the node before listing children on a suspicious stream\nexists, _, err := zkClient.Exists(path)\nif err != nil || !exists {\n    return fmt.Errorf(\"node %q unavailable: %v\", path, err)\n}","typeGuard":"func isInvalidVectorLength(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"invalid ZooKeeper string vector length\")\n}","tryCatchPattern":"children, _, err := zkClient.Children(path)\nif isInvalidVectorLength(err) {\n    zkClient.Close()\n    zkClient = redial() // misaligned stream; re-dial and retry once\n    children, _, err = zkClient.Children(path)\n}\nif err != nil {\n    return err\n}","preventionTips":["Treat any decoder error as fatal to the connection: close and re-dial immediately.","Guard shared clients with a mutex so responses cannot interleave across goroutines.","Verify the endpoint is a real ZooKeeper quorum member before heavy use.","Keep child counts manageable by nesting (shard children across parent znodes)."],"tags":["zookeeper","decoder","vector-length","protocol"],"backgroundTag":"malformed-response-frame","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"}