Skip to content

Commit f90c733

Browse files
committed
schema compile BUGFIX check prefixes even in relative schema-nodeids
1 parent 08ef047 commit f90c733

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/schema_compile_amend.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ lys_schema_node_get_module(const struct ly_ctx *ctx, const char *prefix_dict, co
182182
}
183183

184184
/* prefix module not found */
185-
LOGVAL(ctx, NULL, LYVE_REFERENCE, "Invalid absolute-schema-nodeid nametest - prefix \"%s\" not defined in module \"%s\".",
185+
LOGVAL(ctx, NULL, LYVE_REFERENCE, "Invalid schema-nodeid nametest - prefix \"%s\" not defined in module \"%s\".",
186186
prefix_dict, LYSP_MODULE_NAME(pmod));
187187
return NULL;
188188
}
@@ -254,9 +254,7 @@ lys_nodeid_mod_check(struct lysc_ctx *ctx, const char *str, ly_bool abs, struct
254254
if (abs || nodeid) {
255255
/* compile into nodeid, only if needed */
256256
LY_CHECK_GOTO(ret = lys_precompile_nodeid(ctx->ctx, str, &ni), cleanup);
257-
}
258257

259-
if (abs) {
260258
for (i = 0; i < ni->count; ++i) {
261259
mod = (struct lys_module *)lys_schema_node_get_module(ctx->ctx, ni->prefix[i], ctx->pmod);
262260
LY_CHECK_ERR_GOTO(!mod, ret = LY_EVALID, cleanup);

tests/utests/schema/test_tree_schema_compile.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,6 +2872,22 @@ test_refine(void **state)
28722872
"uses g:grp {refine c/ll {min-elements 1;}}}", LYS_IN_YANG, &mod));
28732873
CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm:{uses='g:grp'}/mm:c/ll", 0);
28742874
CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "/mm:{uses='g:grp'}/mm:c/ll", 0);
2875+
2876+
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn {namespace urn:nn; prefix nn;"
2877+
"grouping test-group {"
2878+
" container cont {"
2879+
" leaf my-leaf {type string;}"
2880+
" }"
2881+
"}"
2882+
"container test-container {"
2883+
" uses test-group {"
2884+
" refine \"invalid:my-leaf\" {"
2885+
" description \"test\";"
2886+
" }"
2887+
" }"
2888+
"}}", LYS_IN_YANG, &mod));
2889+
CHECK_LOG_CTX("Invalid schema-nodeid nametest - prefix \"invalid\" not defined in module \"nn\".",
2890+
"/nn:test-container/{uses='test-group'}/{refine='invalid:my-leaf'}", 0);
28752891
}
28762892

28772893
static void

0 commit comments

Comments
 (0)