{"record":{"id":"e3d180df994e1af8","repo":"apache/beam","slug":"unable-to-decode-array-iterable-with-size-d","errorCode":null,"errorMessage":"unable to decode array iterable with size: %d","messagePattern":"unable to decode array iterable with size: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/coder/iterable.go","lineNumber":149,"sourceCode":"func iterableDecoderForArray(rt reflect.Type, decodeToElem typeDecoderFieldReflect) func(reflect.Value, io.Reader) error {\n\treturn func(ret reflect.Value, r io.Reader) error {\n\t\t// (1) Read count prefixed encoded data\n\t\tsize, err := DecodeInt32(r)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tn := int(size)\n\t\tif rt.Len() != n {\n\t\t\treturn errors.Errorf(\"len mismatch decoding a %v: want %d got %d\", rt, rt.Len(), n)\n\t\t}\n\t\tswitch {\n\t\tcase n >= 0:\n\t\t\tif err := decodeToIterable(ret, r, decodeToElem); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"unable to decode array iterable with size: %d\", n)\n\t\t}\n\t}\n}\n\nfunc decodeToIterable(rv reflect.Value, r io.Reader, decodeTo typeDecoderFieldReflect) error {\n\tsize := rv.Len()\n\tfor i := 0; i < size; i++ {\n\t\tiv := rv.Index(i)\n\t\tif decodeTo.addr {\n\t\t\tiv = iv.Addr()\n\t\t}\n\t\tif err := decodeTo.decode(iv, r); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/coder/iterable.go#L131-L167","documentation":"When decoding an array-typed iterable, after the length check the decoded size n must be >= 0; if n is negative the decoder hits the default branch and errors with \"unable to decode array iterable with size: %d\". Negative sizes are invalid for the fixed-size array iterable variant and indicate corrupt or incompatibly encoded data.","triggerScenarios":"Decoding an array iterable stream whose int32 size field is negative — usually the unknown-size sentinel written by a slice/variadic iterable being read by an array decoder.","commonSituations":"Coder-type mismatch: an upstream stage writes a variadic iterable (negative size sentinel) but the downstream decoder expects a fixed-size array; corrupted streams from cross-version replay.","solutions":["Verify the coder used at encode time matches the array type at decode time","Re-encode data with a coder consistent with the target array type","Check Beam versions on the writer and reader match"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"v, err := decodeArray(r)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to decode array iterable with size\") {\n        return nil, fmt.Errorf(\"array iterable stream has invalid/negative size, coder mismatch: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Match the coder variant (slice vs array) on both encode and decode sides","Pin the same Beam version across all pipeline stages","Treat negative size sentinels as a sign the wrong decoder is being used"],"tags":["go","beam","iterable","decoding"],"backgroundTag":"unexpected-response-shape","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}