deviation replace config when config not be defined explicitly will cause issue
Build test.yang without explicitly config property to cdata(I think this should have default value 'config true') and then build test-deviations.yang try to make the node config to false, but it failed.
test.yang
module test {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:test";
prefix "test";
container cdata {
}
}
test-deviations.yang
module test-deviations {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:test-deviations";
prefix test-deviations;
import test {
prefix test;
}
deviation "/test:cdata" {
deviate replace {
config false;
}
}
}
libyang.so.2.29.2
yanglint 2.1.30
yanglint
> add test.yang
> add test-deviations.yang
libyang[0]: Invalid deviation replacing "config" property "config false" which is not present. (path: /test-deviations:{deviation='/test:cdata/test:id'})
Only I explicitly define 'config true' in test.yang, test-deviations.yang can pass verification.
module test {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:test";
prefix "test";
container cdata {
config true;
}
}
> add /data/libyang2/omu-sdk_lysp/test/src/ut/shy/yang-repo1/test.yang
> add /data/libyang2/omu-sdk_lysp/test/src/ut/shy/yang-repo1/test-deviations.yang
When I search code, I find that lysp_node does not set default node config property and lysc_node set default config(LYS_CONFIG_W) when the property not be defined explicitly but devation validation uses lysp_node to validate.
Do you think this is a issue? thanks. @michalvasko
How this has been defined is a bit unfortunate but we have implemented the specs faithfully. You can only replace explicit statements and config is not explicit in cdata. So you must use deviate add instead as config is allowed for both add and replace.
@michalvasko thank you for your reply. I find that libyang1.* does not have this issue.
module test {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:test";
prefix "test";
container cdata {
}
}
module test-deviations {
yang-version 1.1;
namespace "urn:huawei:yang:test-deviations";
prefix test-deviations;
import test {
prefix test;
}
deviation "/test:cdata" {
deviate replace {
config false;
}
}
}
yanglint SO 1.10.32
> add test.yang
> add test-deviations.yang
> print test
module: test
+--ro cdata
why has inconsistent implementation between libyang1 and libyang2? thanks.
I find that libyang1.* does not have this issue.
I would rather say that libyang1 has this issue (it does not follow the specification exactly).
why has inconsistent implementation between libyang1 and libyang2?
Because there were lots of such seemingly minor problems in libyang1 that eventually led to critical problems that could not be solved without major refactoring of some large code. So that is exactly what we did, wrote everything from scratch the correct way fixing all of that, which resulted in libyang2.
RFC7950 point that :
If the top node does not specify a "config" statement, the default is "true".
and combine with this rule:
If "config" is not specified, the default is the same as the parent schema node's "config" value.
I think libyang2 may be not follow the specification exactly.
https://www.rfc-editor.org/rfc/rfc7950.html#section-7.21.1

Please verify agagin, thanks. @michalvasko
The text you referenced does not specify that the config property exists if it is not defined, just what it defaults to for the purposes of deciding whether a node is a configuration or state node but I agree it is confusing. None of this matters anyway because the reason we have implemented it the way we have is in the ABNF grammar I have referenced in my first reply. Look at the deviate-add-stmt, why is it allowed to add config statement if, based on your interpretation, every single node always has it?