Skip to content

Commit

Permalink
be a bit more descriptive about what triggered the error
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jan 23, 2025
1 parent 4f41886 commit d56525c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/server/tmpl_tokenize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ static fr_slen_t tmpl_attr_parse_filter(tmpl_attr_error_t *err, tmpl_attr_t *ar,
if (slen <= 0) goto error;

if (!tmpl_is_attr(ar->ar_tmpl)) {
fr_strerror_const("Invalid array index");
fr_strerror_printf("Invalid array index '%s'", ar->ar_tmpl->name);
goto error;
}

Expand Down
6 changes: 3 additions & 3 deletions src/tests/unit/condition/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ match (&26.24757.84.9.5.15 == 0x1a99)
# Invalid array references.
#
condition &User-Name[a] == 'bob'
match ERROR offset 12: Invalid array index
match ERROR offset 12: Invalid array index 'a'

condition &User-Name == &Filter-Id[a]
match ERROR offset 26: Invalid array index
match ERROR offset 26: Invalid array index 'a'

#
# Bounds checks...
Expand All @@ -538,7 +538,7 @@ condition &User-Name[1001] == 'bob'
match ERROR offset 12: Invalid array index '1001' (should be between 0-1000)

condition &User-Name[-1] == 'bob'
match ERROR offset 12: Invalid array index
match ERROR offset 12: Invalid array index '-1'

#
# Sometimes the attribute/condition parser needs to fallback to bare words
Expand Down
2 changes: 1 addition & 1 deletion src/tests/unit/condition/filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ condition &User-Name[n] == "foo"
match (&User-Name[n] == "foo")

condition &User-Name[-1] == "foo"
match ERROR offset 12: Invalid array index
match ERROR offset 12: Invalid array index '-1'

#
# tmpl_dcursor.c has an assert which fails if you try to use
Expand Down
6 changes: 3 additions & 3 deletions src/tests/unit/xlat/cond_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ match ERROR offset 18: Unknown attributes not allowed here
# Invalid array references.
#
xlat_purify &User-Name[a] == 'bob'
match ERROR offset 12: Invalid array index
match ERROR offset 12: Invalid array index 'a'

xlat_purify &User-Name == &Filter-Id[a]
match ERROR offset 26: Invalid array index
match ERROR offset 26: Invalid array index 'a'

#
# Bounds checks...
Expand All @@ -539,7 +539,7 @@ xlat_purify &User-Name[1001] == 'bob'
match ERROR offset 12: Invalid array index '1001' (should be between 0-1000)

xlat_purify &User-Name[-1] == 'bob'
match ERROR offset 12: Invalid array index
match ERROR offset 12: Invalid array index '-1'

#
# attributes MUST be prefixed with '&'.
Expand Down

0 comments on commit d56525c

Please sign in to comment.