libyang icon indicating copy to clipboard operation
libyang copied to clipboard

Different error-message between duplicate action and duplicate rpc

Open lyzliyuzhi91 opened this issue 2 years ago • 1 comments

module:

module st-action {
    yang-version 1.1;
    namespace "urn:test:st-action";
    prefix ydb-st-action;
    container c1 {
        list l1 {
            key k1;
            leaf k1 { type string; }
            action a1;
            action act-dup;
        }
    }

    rpc rpc-case {
        input {
            choice choi {
                case ca1 {
                    leaf leaf-ca1 {
                        type string;
                    }
                }
                case ca2 {
                    leaf leaf-ca2 {
                        type string;
                    }
                }
            }
        }
    }
}

When I call `lyd_parse_op' like:

lyd_parse_op(ly_ctx, NULL, in, format, LYD_TYPE_RPC_YANG, &tree, &action)

for duplicate action:

"{\"xxx-st-action:c1\":{\"l1\":[{"k1":"xx","act-dup":{},"act-dup":{}}]}}"

it reports:

"Unexpected action element \"act-dup\", action \"act-dup\" already parsed."

but for duplicate rpc:

"{\"st-action:rpc-case\":{\"leaf-ca1\":\"xx\"},\"st-action:rpc-case\":{\"leaf-ca2\":\"xx\"}}"

it reports:

"Unexpected sibling node."

I think the situation of duplication rpc shoud be similar with the situation of duplicate action. libyang 2.1.30. thanks.

lyzliyuzhi91 avatar Aug 14 '23 12:08 lyzliyuzhi91

I think the situation of duplication rpc shoud be similar with the situation of duplicate action.

But is not, is that really a problem? An action can have a sibling in case it is in a list, the list key. No such node is expected for an RPC, hence the minor difference.

michalvasko avatar Aug 15 '23 08:08 michalvasko