List instance is missing its key error while parse
hi
When I try to use libyang 2.1.30 to parse the
Here's the modeling information I've provided:
container OCSStatuss {
list OCSStatus {
key "HostName ResourceUnit LocAddr SubLocAddr OCSAddr";
config false;
description
"OCS Status";
leaf RecId {
type uint32 {
range "0..4294967295";
}
mandatory false;
description
"Record ID";
mo:indexAssignMode "INC";
}
leaf HostName {
type string {
length "0..127";
}
mandatory false;
description
"OCS Host Name";
mo:indexAssignMode "MIN";
}
leaf SpuGrp {
type uint32 {
range "1";
}
mandatory false;
description
"SPU Group ID";
mo:indexAssignMode "MIN";
}
leaf ResourceUnit {
type string {
length "0..63";
}
mandatory false;
description
"RU Name";
mo:indexAssignMode "MIN";
}
leaf LocAddr {
type string {
length "0..63";
}
mandatory false;
description
"Local Address";
mo:indexAssignMode "MIN";
}
leaf SubLocAddr {
type string {
length "0..63";
}
mandatory false;
description
"Local Sub-Address";
mo:indexAssignMode "MIN";
}
leaf OCSAddr {
type string {
length "0..63";
}
mandatory false;
description
"Peer Address";
mo:indexAssignMode "MIN";
}
leaf LocalHostName {
type string {
length "0..127";
}
mandatory false;
description
"Local Host Name";
mo:indexAssignMode "MIN";
}
}
}
This is the get request message I sent:
According to the node parameter of the lyd_parse_check_keys function, the key field OCSAddr is behind a non-key. As a result, the function reports an error.
What netopeer2-server version are you using? It worked fine using the current devel version.
The libnetconf2 2.1.28 version is used.
I reconstructed another model, and it worked fine, as shown in the following figure.
But once I used the above mentioned model "OCSStatuss", the problem revealed that none of my other behaviors changed, which I was puzzled by.
I have tested your exact module and could not reproduce it.
I tried to verify the problem with different versions and found that the problem was fixed between 2.1.111 and 2.1.128.
Have you fixed this problem between the two versions?
If there is a similar commit record for my reference, I would appreciate it.
You are free to go commit-by-commit and find the one that fixed it, but it is not part of the support we provide.
Hello, this problem recurs when I trigger the same operation above with the new yang model, and I am using libyang version 2.1.128:
typedef SUBSINFO_TYPE {
type enumeration {
enum "LOCAL_AGGR_EVT" {
description
"Local Aggregation Event";
value 4;
}
enum "LOCAL_FLT_EVT" {
description
"Local Filter Event";
value 3;
}
enum "LOCAL_RPT_EVT" {
description
"Local RPT Event";
value 2;
}
enum "LOCAL_TOPN_EVT" {
description
"Local Topn Event";
value 5;
}
enum "SUBS_CONFIG" {
description
"Subscription configuration";
value 1;
}
enum "SUBS_POLICY" {
description
"Subscription Policy";
value 0;
}
}
}
typedef SUBS_CONFIG_TYPE {
type enumeration {
enum "CONFIG_TYPE_FILTERGROUP" {
description
"Config Filter Group";
value 1;
}
enum "CONFIG_TYPE_HIGHBAND" {
description
"High-bandwidth User Rule";
value 3;
}
enum "CONFIG_TYPE_QOSMONITOR" {
description
"Qos Monitor Rule";
value 2;
}
enum "CONFIG_TYPE_REALRPT" {
description
"Real Report";
value 0;
}
enum "CONFIG_TYPE_USRTATS" {
description
"UserStats";
value 5;
}
enum "CONFIG_TYPE_VVIP" {
description
"VVIP";
value 4;
}
enum "CONFIG_TYPE_CCO_ABRVIDEO" {
description
"CCO ABR Video Rule";
value 7;
}
enum "CONFIG_TYPE_CCO_CELLLEVEL" {
description
"CCO Cell Level Rule";
value 8;
}
enum "CONFIG_TYPE_CCO_CELLSPEC" {
description
"CCO Cell Spec Rule";
value 6;
}
enum "CONFIG_TYPE_CCO_CTRL" {
description
"CCO Ctrl Rule";
value 9;
}
}
}
container RptSubsInfos {
list RptSubsInfo {
key "Result";
config false;
description
"Display Report Subscribe Information";
leaf Type {
type SUBSINFO_TYPE;
mandatory false;
description
"Type";
mo:indexAssignMode "MIN";
}
leaf SubsPolicyId {
type uint32 {
range "0..4294967295";
}
mandatory false;
description
"Subscribe Policy ID";
mo:indexAssignMode "MIN";
}
leaf Result {
type string {
length "0..29000";
}
mandatory false;
description
"Result";
mo:indexAssignMode "MIN";
}
leaf SubsConfigType {
type SUBS_CONFIG_TYPE;
mandatory false;
description
"Subscription Configuration Type";
mo:indexAssignMode "MIN";
}
}
}
I triggered this with the following netconf get request:
<?xml version="1.0" encoding="UTF8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1" pid="1766902592">
<get>
<filter type="subtree">
<RptSubsInfos xmlns="test:test-rfc6241">
<RptSubsInfo>
<Type>SUBS_CONFIG</Type>
<SubsPolicyId/>
<Result/>
<SubsConfigType>CONFIG_TYPE_FILTERGROUP</SubsConfigType>
</RptSubsInfo>
</RptSubsInfos>
</filter>
</get>
</rpc>
Here are my test results:
By printing the content in the lyd_insert_node function, I found that when the key is inserted into the third node or later, first_sibling->prev equals first_sibling->next. As a result, the key cannot be inserted into the first node.
The above part comes from the commit record:
https://github.com/CESNET/libyang/commit/6a0bb25952429185c42974d6dab31bbf39083925
Finally, the lyd_parse_check_keys function fails. The information about the node parameter is as follows:
Thanks for the example, it should be fixed in the latest libyang, test added into netopeer2.
@michalvasko @sicongPang I've had the same problem, but I don't think it's a bug. According to RFC7950 7.8.5: The rest of the list’s child nodes are encoded as subelements to the list element, after the keys.
Fair enough, I suppose it can be considered to be a minor extension but it is generally accepted that this should be supported in practice.