{"record":{"id":"45428cd18fbe6b18","repo":"apache/druid","slug":"second-argument-must-be-a-base64-encoded-string-va","errorCode":null,"errorMessage":"second argument must be a base64 encoded STRING value but got %s instead","messagePattern":"second argument must be a base64 encoded STRING value but got (.+?) instead","errorType":"validation","errorClass":"ExpressionValidationException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java","lineNumber":112,"sourceCode":"\n      @Override\n      public ExprEval<?> eval(ObjectBinding bindings)\n      {\n        ExprEval<?> toDecode = args.get(1).eval(bindings);\n        if (toDecode.value() == null) {\n          return ExprEval.ofComplex(complexType, null);\n        }\n        final Object serializedValue = toDecode.value();\n        final byte[] base64;\n        if (serializedValue instanceof String) {\n          base64 = StringUtils.decodeBase64String(toDecode.asString());\n        } else if (serializedValue instanceof byte[]) {\n          base64 = (byte[]) serializedValue;\n        } else if (complexType.getComplexTypeName().equals(toDecode.type().getComplexTypeName())) {\n          // pass it through, it is already the right thing\n          return toDecode;\n        } else {\n          throw validationFailed(\n              \"second argument must be a base64 encoded STRING value but got %s instead\",\n              toDecode.type()\n          );\n        }\n\n        return ExprEval.ofComplex(complexType, typeStrategy.fromBytes(base64));\n      }\n\n      @Nullable\n      @Override\n      public ExpressionType getOutputType(InputBindingInspector inspector)\n      {\n        return complexType;\n      }\n\n      @Override\n      public boolean isLiteral()\n      {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java#L94-L130","documentation":"In complex_decode_base64's eval, the second argument must decode to a base64-encoded STRING (or byte[]) of the declared complex type; if it is already a deserialized value of the matching complex type it is passed through, otherwise this validationFailed is thrown describing the actual type of the second argument.","triggerScenarios":"Second argument evaluates to a non-string/non-byte[] value of a different type — e.g. a long, double, array, or a complex value of a mismatched complex type name.","commonSituations":"Pointing the function at the wrong column (raw long/JSON column instead of base64 string); decoding a column serialized with a different complex type than declared in arg 1.","solutions":["Pass the column that holds base64-encoded STRING data.","Ensure the declared complex type (arg 1) matches the type the column was serialized with.","Cast the second argument to VARCHAR if it is numeric: complex_decode_base64('type', CAST(col AS VARCHAR)).","Inspect the column's actual type via segment metadata or EXPLAIN."],"exampleFix":"// before\ncomplex_decode_base64('druid.metrics.snapshot', numeric_col)\n// after\ncomplex_decode_base64('druid.metrics.snapshot', base64_string_col)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["druid","expressions","base64","type-mismatch"],"backgroundTag":"invalid-argument-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}