Skip to content

Commit 5dca593

Browse files
committed
schema parsers CHANGE reaction to failure of default value resolving
In some cases, the failure in parsing default value can be caused by possible forward reference (leafref, identityref), so isntead of immediate error, we should try it later again as an unresolved item.
1 parent bfe379d commit 5dca593

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/resolve.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,8 @@ check_default(struct lys_type *type, const char **value, struct lys_module *modu
30673067
}
30683068
} else {
30693069
if (!lyp_parse_value(&((struct lys_node_leaf *)node.schema)->type, &node.value_str, NULL, NULL, &node, 1, 1)) {
3070-
ret = -1;
3070+
/* possible forward reference */
3071+
ret = 1;
30713072
if (base_tpdf) {
30723073
/* default value is defined in some base typedef */
30733074
if ((type->base == LY_TYPE_BITS && type->der->type.der) ||
@@ -5055,7 +5056,7 @@ resolve_base_ident(const struct lys_module *module, struct lys_ident *ident, con
50555056
*
50565057
* @param[in] type Identityref type.
50575058
* @param[in] ident_name Identityref name.
5058-
* @param[in] node Node where the identityref is being resolved, if NULL the logging is switched off
5059+
* @param[in] node Node where the identityref is being resolved
50595060
*
50605061
* @return Pointer to the identity resolvent, NULL on error.
50615062
*/
@@ -5075,11 +5076,17 @@ resolve_identref(struct lys_type *type, const char *ident_name, struct lyd_node
50755076
if (rc < 1) {
50765077
if (node) {
50775078
LOGVAL(LYE_INCHAR, LY_VLOG_LYD, node, ident_name[-rc], &ident_name[-rc]);
5079+
} else {
5080+
LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid identityref value \"%s\".", ident_name);
5081+
ly_vecode = LYVE_INCHAR;
50785082
}
50795083
return NULL;
50805084
} else if (rc < (signed)strlen(ident_name)) {
50815085
if (node) {
50825086
LOGVAL(LYE_INCHAR, LY_VLOG_LYD, node, ident_name[rc], &ident_name[rc]);
5087+
} else {
5088+
LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid identityref value \"%s\".", ident_name);
5089+
ly_vecode = LYVE_INCHAR;
50835090
}
50845091
return NULL;
50855092
}
@@ -5111,6 +5118,9 @@ resolve_identref(struct lys_type *type, const char *ident_name, struct lyd_node
51115118

51125119
if (node) {
51135120
LOGVAL(LYE_INRESOLV, LY_VLOG_LYD, node, "identityref", ident_name);
5121+
} else {
5122+
LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid identityref value \"%s\".", ident_name);
5123+
ly_vecode = LYVE_INRESOLV;
51145124
}
51155125
return NULL;
51165126

@@ -5121,6 +5131,10 @@ resolve_identref(struct lys_type *type, const char *ident_name, struct lyd_node
51215131
LOGVAL(LYE_INVAL, LY_VLOG_LYD, node, cur->name, node->schema->name);
51225132
LOGVAL(LYE_SPEC, LY_VLOG_LYD, node, "Identity \"%s\" is disabled by its if-feature condition.",
51235133
cur->name);
5134+
} else {
5135+
LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Identity \"%s\" is disabled by its if-feature condition.",
5136+
cur->name);
5137+
ly_vecode = LYVE_INVAL;
51245138
}
51255139
return NULL;
51265140
}

0 commit comments

Comments
 (0)