Skip to content

Error when calling nc_recv_reply with empty rpc-reply #549

@jeremie6wind

Description

@jeremie6wind

Hi,
I have an RPC callback that returns nothing in an output container, no data in the leaf "ret".

rpc oper {
    output {
        container mycont {
            leaf ret {
                type int64;
          }
        }
    }
}

This leads to the following rpc-reply received by the client:

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="X">
</rpc-reply>

which gives an error when calling the nc_recv_reply function, as there is no 'ok' and no data.

  • There is no error when the leaf ret is not in a container(mycont removed). The leaf 'ok' is present.
  • There is no error when the "presence" statement is present in the container . The leaf 'ok' is present.
  • There is no bug if the LYD_PRINT_KEEPEMPTYCONT is present when building the reply in src/io.c in nc_write_msg_io :
    lyrc = lyd_print_clb(nc_write_xmlclb, (void *)&arg, reply_envp, LYD_XML, LYD_PRINT_SHRINK | wd | LYD_PRINT_KEEPEMPTYCONT);
    The empty container mycont is present in the rpc-reply.

Maybe it is also possible to modify nc_server_reply_data to see if the output contains data or empty container or empty list? If it does not contains a leaf add the 'ok' leaf?

BR
Jeremie

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions