Skip to content

validation failed: Missing required element "content-id" in "yang-library". #21

Closed

Description

@gwieser1234

Hi,

I am trying to build a data tree based on the example that you have provided. I can load the schema, but I was not able to create a data tree. I am getting an error: "libyang.util.LibyangError: validation failed: Missing required element "content-id" in "yang-library".

Any pointer is much appreciated.

ctx = libyang.Context()
module = ctx.parse_module_str('''
... module example {
... namespace "urn:example";
... prefix "ex";
... container data {
... list interface {
... key name;
... leaf name {
... type string;
... }
... leaf address {
... type string;
... }
... }
... leaf hostname {
... type string;
... }
... }
... }
... ''')

print(module.print_mem('tree'))
module: example
+--rw data
+--rw interface* [name]
| +--rw name string
| +--rw address? string
+--rw hostname? string

node = module.parse_data_dict({
... 'data': {
... 'hostname': 'foobar',
... 'interface': [
... {'name': 'eth0', 'address': '1.2.3.4/24'},
... {'name': 'lo', 'address': '127.0.0.1'},
... ],
... },
... })
Traceback (most recent call last):
File "", line 6, in
File "/home/gwieser/libyang-python-test01/venv/lib/python3.6/site-packages/libyang/schema.py", line 190, in parse_data_dict
validate=validate,
File "/home/gwieser/libyang-python-test01/venv/lib/python3.6/site-packages/libyang/data.py", line 903, in dict_to_dnode
no_yanglib=no_yanglib,
File "/home/gwieser/libyang-python-test01/venv/lib/python3.6/site-packages/libyang/data.py", line 282, in validate
raise self.context.error("validation failed")
libyang.util.LibyangError: validation failed: Missing required element "content-id" in "yang-library".

Activity

  1. self-assigned this
    on Mar 25, 2021
  2. rjarry commented on Mar 25, 2021

    @rjarry
    Collaborator

    Hi @gwieser1234

    Indeed, the example is incorrect, I will fix the README.

  3. added 2 commits that reference this issue on Mar 25, 2021
    0130821
    b3c6f76
  4. added a commit that references this issue on Mar 25, 2021
    c22f10a
  5. gwieser1234 commented on Mar 25, 2021

    @gwieser1234
    Author

    HI Robin, thank you that fixed it. Its working now.

  6. savnishsingh commented on Nov 16, 2022

    @savnishsingh

    Hi Robin,
    I am facing the same issue with libyang-python.
    When i use
    ctx.parse_data_mem(xml_tree, "xml",strict=True)
    i receive this error

    <nc:error-info>failed to parse data tree: Mandatory node "content-id" instance does not exist.</nc:error-info>

    The RPC that i am trying contains this data,

    <rpc>
        <edit-config>
          <target>
            <running/>
          </target>
            <config>
                <ManagedElement xmlns="urn:3gpp:sa5:_3gpp-common-managed-element">
                  <id>O1/mns/ManagedElement-Single/123456</id>
                  <GNBDUFunction xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-gnbdufunction">
                    <id>O1/mns/GnbDuFunction-Single/123456:5</id>
                    <NRCellDU xmlns="urn:3gpp:sa5:_3gpp-nr-nrm-nrcelldu">
                      <id>O1/mns/NrCellDu-Single/123456:011</id>
                      <attributes>
                            <nRPCI>17</nRPCI>
                            <arfcnDL>140001</arfcnDL>
                            <arfcnUL>140002</arfcnUL>
                            <ssbFrequency>703</ssbFrequency>
                      </attributes>
                    </NRCellDU>
                  </GNBDUFunction>
                </ManagedElement>
            </config>
        </edit-config>
    </rpc>
    

    I believe get_yanglib_data is needed here but i don't understand completely how to get around this error

  7. rjarry commented on Nov 16, 2022

    @rjarry
    Collaborator
  8. savnishsingh commented on Nov 16, 2022

    @savnishsingh

    Actually, i had exactly same error so i thought it might be related and not a new issue.
    So, from the link are you suggesting me to use this flag LYD_PARSE_SUBTREE? Because i have tried all others and it leads to same issue or it doesn't validate the tree with the PARSE_ONLY flag.

  9. rjarry commented on Nov 16, 2022

    @rjarry
    Collaborator

    The issue was reported with libyang 1 which is completely different.

    I think rpc input cannot be validated without the complete datastore at hand (which you don't have in your case). So PARSE_ONLY makes a lot of sense. Maybe you should ask on the libyang project itself how to parse rpc input data. The python bindings don't do anything fancy besides wrapping the C API.

  10. savnishsingh commented on Nov 16, 2022

    @savnishsingh

    Thanks Robin. I'll try the libyang project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions