]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clarify error message and fix test
authorAlan T. DeKok <aland@freeradius.org>
Mon, 18 Aug 2025 16:01:33 +0000 (12:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 18 Aug 2025 20:05:30 +0000 (16:05 -0400)
src/lib/util/dict_fixup.c
src/tests/dict/base.dict

index 72bf7b7b65f22fdd631ff230317bedad420775bd..f10989427844ed5ad7c6fe49be2dff9064daac33 100644 (file)
@@ -210,14 +210,20 @@ int fr_dict_protocol_reference(fr_dict_attr_t const **da_p, fr_dict_attr_t const
                da = dict->root;
        }
 
+       /*
+        *      ref=.foo is a ref from the current parent.
+        *
+        *      ref=@foo is a ref from the root of the tree.
+        */
+
        if (!fr_sbuff_next_if_char(in, '.')) {
-               fr_strerror_printf("Attribute %s has reference '%s' which does not begin with '.' or '@'",
-                                  rel->name, fr_sbuff_start(in));
+               fr_strerror_printf("Invalid reference '%s' - it should start with '@' (from the root), or '.' (from the parent)",
+                                  fr_sbuff_start(in));
                return -1;
        }
 
        /*
-        *      First '.' makes it reletive, subsequent ones traverse up the tree.
+        *      First '.' makes it relative, subsequent ones traverse up the tree.
         *
         *      No '.' means use the root.
         */
@@ -380,8 +386,8 @@ static inline CC_HINT(always_inline) int dict_fixup_group_apply(UNUSED dict_fixu
 
        (void) fr_dict_protocol_reference(&da, fixup->da->parent, &FR_SBUFF_IN_STR(fixup->ref));
        if (!da) {
-               fr_strerror_printf_push("Failed resolving reference for attribute at %s[%d]",
-                                       fr_cwd_strip(fixup->da->filename), fixup->da->line);
+               fr_strerror_printf_push("Failed resolving reference for attribute %s at %s[%d]",
+                                       fixup->da->name, fr_cwd_strip(fixup->da->filename), fixup->da->line);
                return -1;
        }
 
@@ -603,8 +609,8 @@ static inline CC_HINT(always_inline) int dict_fixup_clone_apply(UNUSED dict_fixu
 
        (void) fr_dict_protocol_reference(&src, fixup->da->parent, &FR_SBUFF_IN_STR(fixup->ref));
        if (!src) {
-               fr_strerror_printf_push("Failed resolving reference for attribute at %s[%d]",
-                                       fr_cwd_strip(fixup->da->filename), fixup->da->line);
+               fr_strerror_printf_push("Failed resolving reference for attribute %s at %s[%d]",
+                                       fixup->da->name, fr_cwd_strip(fixup->da->filename), fixup->da->line);
                return -1;
        }
 
@@ -662,8 +668,8 @@ static inline CC_HINT(always_inline) int dict_fixup_clone_enum_apply(UNUSED dict
 
        (void) fr_dict_protocol_reference(&src, fixup->da->parent, &FR_SBUFF_IN_STR(fixup->ref));
        if (!src) {
-               fr_strerror_printf_push("Failed resolving reference for attribute at %s[%d]",
-                                       fr_cwd_strip(fixup->da->filename), fixup->da->line);
+               fr_strerror_printf_push("Failed resolving reference for attribute %s at %s[%d]",
+                                       fixup->da->name, fr_cwd_strip(fixup->da->filename), fixup->da->line);
                return -1;
        }
 
index c20dba48db058f9cd6937004cfbbbd5c63050869..8307cf5e14b77ae8a9c84af65b97de5a1b9961dd 100644 (file)
@@ -38,11 +38,11 @@ VALUE base-enum-uint64 one  1
 VALUE base-enum-uint64 two     2
 VALUE base-enum-uint64 three   3
 
-ATTRIBUTE      Base-Integer64                          19      uint64 enum=base-enum-uint64
+ATTRIBUTE      Base-Integer64                          19      uint64 enum=.base-enum-uint64
 ATTRIBUTE      Base-IPv4-Prefix                        20      ipv4prefix
 
 #  and this casting should work
-ATTRIBUTE      Base-Integer32                          21      uint32  enum=base-enum-uint64
+ATTRIBUTE      Base-Integer32                          21      uint32  enum=.base-enum-uint64
 
 # Ignore VSA, VENDOR, timeval, boolean, combo-ip-prefix, decimal... for now
 END-PROTOCOL TEST