@@ -256,7 +256,7 @@ static unlang_action_t unlang_foreach_xlat_next(rlm_rcode_t *p_result, request_t
256256 * p_result = frame -> result ;
257257 return UNLANG_ACTION_CALCULATE_RESULT ;
258258 }
259-
259+
260260 if (unlang_foreach_xlat_key_update (request , state ) < 0 ) goto next ;
261261
262262 fr_value_box_clear_value (& state -> value -> data );
@@ -418,7 +418,7 @@ static unlang_action_t unlang_foreach_attr_next(rlm_rcode_t *p_result, request_t
418418 }
419419
420420 } else if (fr_type_is_structural (vp -> vp_type )) {
421- fr_assert (state -> value -> vp_type == vp -> vp_type );
421+ if (state -> value -> vp_type != vp -> vp_type ) goto next ;
422422
423423 fr_pair_list_free (& state -> value -> vp_group );
424424
@@ -486,6 +486,7 @@ static unlang_action_t unlang_foreach_attr_init(rlm_rcode_t *p_result, request_t
486486 vp = tmpl_dcursor_init (NULL , NULL , & state -> cc , & state -> cursor , request , state -> vpt );
487487 fr_assert (vp != NULL );
488488
489+ next :
489490 /*
490491 * Update the key with the current path. Attribute indexes start at zero.
491492 */
@@ -500,13 +501,17 @@ static unlang_action_t unlang_foreach_attr_init(rlm_rcode_t *p_result, request_t
500501 }
501502
502503 } else if (fr_type_is_structural (vp -> vp_type )) {
503- if (state -> value -> vp_type == vp -> vp_type ) {
504- if (unlang_foreach_pair_copy (state -> value , vp , vp -> da ) < 0 ) {
505- REDEBUG ("Failed copying children of %s" , state -> value -> da -> name );
506- goto fail ;
507- }
508- } else {
509- REDEBUG ("Failed initializing loop variable %s - expected %s type, but got input (%pP)" , state -> value -> da -> name , fr_type_to_str (state -> value -> vp_type ), vp );
504+ if (state -> value -> vp_type != vp -> vp_type ) {
505+ vp = fr_dcursor_next (& state -> cursor );
506+ if (vp ) goto next ;
507+
508+ * p_result = frame -> result ;
509+ fr_assert (state -> indent == request -> log .indent .unlang );
510+ return UNLANG_ACTION_CALCULATE_RESULT ;
511+ }
512+
513+ if (unlang_foreach_pair_copy (state -> value , vp , vp -> da ) < 0 ) {
514+ REDEBUG ("Failed copying children of %s" , state -> value -> da -> name );
510515 goto fail ;
511516 }
512517
0 commit comments