{"record":{"id":"87e4d6207bba312d","repo":"redis/jedis","slug":"default-policy-requires-list-set-map-jedisbyteh","errorCode":null,"errorMessage":"DEFAULT policy requires List, Set, Map, JedisByteHashMap, or JedisByteMap types, but got: ${sample.getClass().getName()}","messagePattern":"DEFAULT policy requires List, Set, Map, JedisByteHashMap, or JedisByteMap types, but got: (.+?)","errorType":"exception","errorClass":"UnsupportedAggregationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/executors/aggregators/DefaultPolicyAggregator.java","lineNumber":64,"sourceCode":"    }\n\n    if (sample instanceof Set) {\n      return (Aggregator<T, T>) new SetAggregator<>();\n    }\n\n    if (sample instanceof JedisByteHashMap) {\n      return (Aggregator<T, T>) new JedisByteHashMapAggregator();\n    }\n\n    if (sample instanceof JedisByteMap) {\n      return (Aggregator<T, T>) new JedisByteMapAggregator<>();\n    }\n\n    if (sample instanceof Map) {\n      return (Aggregator<T, T>) new MapAggregator<>();\n    }\n\n    throw new UnsupportedAggregationException(\n        \"DEFAULT policy requires List, Set, Map, JedisByteHashMap, or JedisByteMap types, but got: \"\n            + sample.getClass().getName());\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":69,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/executors/aggregators/DefaultPolicyAggregator.java#L46-L69","documentation":"DefaultPolicyAggregator implements aggregation for commands using the DEFAULT response policy, which supports merging container types: List, Set, Map, JedisByteHashMap, or JedisByteMap. When the first reply sample is none of these types it throws UnsupportedAggregationException with the actual class name. Scalar replies cannot be merged under the DEFAULT policy.","triggerScenarios":"Broadcasting a command marked with the DEFAULT response policy whose replies are scalars — e.g. a broadcast PING/SET whose reply is a String, STATUS, or Long instead of a collection.","commonSituations":"Applying multi-shard broadcast to commands returning single values (CONFIG GET with a scalar builder, DBSIZE returning Long handled by wrong policy), or custom commands where the declared Builder doesn't produce a container type.","solutions":["Use a response policy appropriate for scalar replies (e.g. FIRST/SUCCESS-ON-ANY) instead of DEFAULT for scalar-returning commands.","If merging is intended, ensure the Builder parses replies into List/Set/Map (e.g. BuilderFactory.STRING_LIST, MAP) so the DEFAULT aggregator can merge them.","For byte-map commands, make sure replies are built as JedisByteHashMap/JedisByteMap rather than plain values."],"exampleFix":"// before\nnew CommandObject<>(args, BuilderFactory.STRING)           // scalar under DEFAULT policy\n// after\nnew CommandObject<>(args, BuilderFactory.STRING_LIST)      // mergeable container","handlingStrategy":"validation","validationCode":"// verify the Builder yields a mergeable container before using the DEFAULT policy\nObject sample = jedis.sendCommand(cmd);\nif (!(sample instanceof List || sample instanceof Set || sample instanceof Map)) {\n  throw new IllegalStateException(\"DEFAULT policy needs a container reply, got \" + sample.getClass());\n}","typeGuard":"boolean isMergeableReply(Object r) {\n  return r instanceof List || r instanceof Set || r instanceof Map;\n}","tryCatchPattern":"try {\n  return broadcastDefault();\n} catch (UnsupportedAggregationException e) {\n  logger.error(\"scalar reply under DEFAULT policy: {}\", e.getMessage());\n  throw new IllegalStateException(e);\n}","preventionTips":["Use container Builders (STRING_LIST, STRING_MAP, etc.) with the DEFAULT policy","Use FIRST/success policies for scalar replies","Test broadcast commands against all shard reply shapes"],"tags":["cluster","aggregation","response-policy","type-mismatch"],"backgroundTag":"unsupported-operation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}