@@ -561,10 +561,7 @@ public Object copyMessage(Object message) {
561561 public Object transformMessage (RuleContext ctx , FieldTransform transform , Object message )
562562 throws RuleException {
563563 try {
564- // Use the schema from the message if it exists, so schema evolution works properly
565- Schema schema = message instanceof GenericContainer
566- ? ((GenericContainer ) message ).getSchema ()
567- : this .rawSchema ();
564+ Schema schema = this .rawSchema ();
568565 return toTransformedMessage (ctx , schema , message , transform );
569566 } catch (RuntimeException e ) {
570567 if (e .getCause () instanceof RuleException ) {
@@ -613,16 +610,27 @@ private Object toTransformedMessage(
613610 if (message == null ) {
614611 return null ;
615612 }
616- data = AvroSchemaUtils .getData (schema , message , false , false );
617- for (Schema .Field f : schema .getFields ()) {
618- String fullName = schema .getFullName () + "." + f .name ();
613+ Schema recordSchema = schema ;
614+ if (message instanceof GenericContainer ) {
615+ // Use the schema from the message if it exists, so schema evolution works properly
616+ recordSchema = ((GenericContainer ) message ).getSchema ();
617+ }
618+ data = AvroSchemaUtils .getData (recordSchema , message , false , false );
619+ for (Schema .Field f : recordSchema .getFields ()) {
620+ // The original field has tags needed for inline tag matching
621+ Schema .Field originalField = schema .getField (f .name ());
622+ if (originalField == null ) {
623+ originalField = f ;
624+ }
625+ String fullName = recordSchema .getFullName () + "." + f .name ();
619626 try (FieldContext fc = ctx .enterField (
620- message , fullName , f .name (), getType (f .schema ()), getInlineTags (f ))) {
627+ message , fullName , f .name (),
628+ getType (originalField .schema ()), getInlineTags (originalField ))) {
621629 Object value = data .getField (message , f .name (), f .pos ());
622630 if (value instanceof Utf8 ) {
623631 value = value .toString ();
624632 }
625- Object newValue = toTransformedMessage (ctx , f .schema (), value , transform );
633+ Object newValue = toTransformedMessage (ctx , originalField .schema (), value , transform );
626634 if (ctx .rule ().getKind () == RuleKind .CONDITION ) {
627635 if (Boolean .FALSE .equals (newValue )) {
628636 throw new RuntimeException (new RuleConditionException (ctx .rule ()));
0 commit comments