{"record":{"id":"46f63f1fbe807356","repo":"apache/druid","slug":"failed-to-deserialize-bloom-filter-46f63f","errorCode":null,"errorMessage":"failed to deserialize bloom filter","messagePattern":"failed to deserialize bloom filter","errorType":"exception","errorClass":"ExpressionProcessingException","httpStatus":null,"severity":"error","filePath":"extensions-core/druid-bloom-filter/src/main/java/org/apache/druid/query/expressions/BloomFilterExpressions.java","lineNumber":328,"sourceCode":"        }\n\n        @Nullable\n        @Override\n        public ExpressionType getOutputType(InputBindingInspector inspector)\n        {\n          return ExpressionType.LONG;\n        }\n      }\n\n      if (filterExpr.isLiteral() && filterExpr.getLiteralValue() instanceof String) {\n        final String serializedFilter = (String) filterExpr.getLiteralValue();\n        final byte[] decoded = StringUtils.decodeBase64String(serializedFilter);\n        BloomKFilter filter;\n        try {\n          filter = BloomFilterSerializersModule.bloomKFilterFromBytes(decoded);\n        }\n        catch (IOException ioe) {\n          throw processingFailed(ioe, \"failed to deserialize bloom filter\");\n        }\n        return new BloomExpr(filter, args);\n      } else {\n        return new DynamicBloomExpr(args);\n      }\n    }\n  }\n}\n","sourceCodeStart":310,"sourceCodeEnd":337,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-bloom-filter/src/main/java/org/apache/druid/query/expressions/BloomFilterExpressions.java#L310-L337","documentation":"When deserializing a base64-encoded BloomKFilter from bytes, an IOException causes the expression code to fail with 'failed to deserialize bloom filter'. This means the serialized filter bytes are corrupt, truncated, or not a valid BloomKFilter format.","triggerScenarios":"Applying a literal bloom filter expression where the base64 string decodes to bytes that BloomFilterSerializersModule.bloomKFilterFromBytes cannot parse.","commonSituations":"Manually constructed/truncated base64 strings; filters serialized by an incompatible Druid version; whitespace or corruption introduced when copying the base64 string; passing a bloom_filter_expr output where a K-filter format is required.","solutions":["Regenerate the base64 filter string with base64_to/from using the same Druid version that will consume it.","Verify the base64 string is complete and has no whitespace or truncation.","Confirm the filter was produced as a BloomKFilter (not another bloom implementation) via bloom_filter_expr."],"exampleFix":"// before\nWHERE filter_bloom(x, 'SGVsbG8')  -- truncated base64\n// after\nWHERE filter_bloom(x, '<full base64 of bloom_filter_expr output>')","handlingStrategy":"try-catch","validationCode":"// sanity-check base64 length before use\nbyte[] decoded = java.util.Base64.getDecoder().decode(b64.trim());\nif (decoded.length < 16) throw new IllegalArgumentException(\"bloom filter base64 too short/corrupt\");","typeGuard":null,"tryCatchPattern":"try { filter_bloom(x, b64Filter); } catch (ExpressionProcessingException e) { /* regenerate filter via bloom_filter_expr and retry */ }","preventionTips":["Copy base64 strings without truncation or whitespace","Generate and consume filters on compatible Druid versions","Always produce filters with bloom_filter_expr, not hand-built bytes"],"tags":["bloom-filter","deserialization","base64"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}