Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XmlSubtreeCodec fails decode payload with augmented component #956

Closed
ygorelik opened this issue Sep 19, 2019 · 1 comment
Closed

XmlSubtreeCodec fails decode payload with augmented component #956

ygorelik opened this issue Sep 19, 2019 · 1 comment
Assignees

Comments

@ygorelik
Copy link
Collaborator

ygorelik commented Sep 19, 2019

Based on reporting from YDK user George Yanev [email protected].

Current Behavior

XmlSubtreeCodec fails decode payload with augmented component and returns exception:

YServiceProviderError: Wrong payload!

Test Case

TEST_CASE("test_augment_leaf")
{
    ydk::path::Repository repo{TEST_HOME};
    ydk::path::NetconfSession session{repo, "127.0.0.1", "admin", "admin", 12022};

    auto i = make_shared<ydktest_sanity::Runner::Passive::Interfac>();
    i->test = "abc";

    auto passive = make_shared<ydktest_sanity::Runner::Passive>();
    passive->name = "xyz";
    passive->interfac.append(i);

    auto r_1 = make_shared<ydktest_sanity::Runner>();
    r_1->passive.append(passive);

    passive->testc->xyz = make_shared<ydktest_sanity::Runner::Passive::Testc::Xyz>();
    passive->testc->xyz->parent = passive.get();
    passive->testc->xyz->xyz = 25;

    CodecServiceProvider codec_provider{EncodingFormat::XML};
    CodecService codec_service{};
    auto xmlC = codec_service.encode(codec_provider, *r_1, true);

    XmlSubtreeCodec xml_codec{};
    auto xmlX = xml_codec.encode(*r_1, session.get_root_schema());
    cout << "XmlSubtreeCodec:\n" << xmlX << endl << endl;
    REQUIRE(xmlC.erase(xmlC.find_last_not_of("\n")+1) == xmlX);

    auto runner = xml_codec.decode(xmlC, make_shared<ydktest_sanity::Runner>());
}

Logs

XmlSubtreeCodec:
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <passive>
    <name>xyz</name>
    <interfac>
      <test>abc</test>
    </interfac>
    <testc xmlns="http://cisco.com/ns/yang/ydktest-sanity-augm">
      <xyz>
        <xyz>25</xyz>
      </xyz>
    </testc>
  </passive>
</runner>

[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'passive' in 'runner'
[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'name' in 'passive'
[2019-09-19 14:59:36.726] [ydk] [debug] XML: Creating leaf 'name' with value 'xyz'
[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'interfac' in 'passive'
[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'test' in 'interfac'
[2019-09-19 14:59:36.726] [ydk] [debug] XML: Creating leaf 'test' with value 'abc'
[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'testc' in 'passive'
[2019-09-19 14:59:36.726] [ydk] [debug] Looking for child 'xyz' in 'passive'
[2019-09-19 14:59:36.726] [ydk] [error] Wrong payload! <xyz> not found
[2019-09-19 14:59:36.727] [ydk] [info] Disconnected from device
[2019-09-19 14:59:36.728] [ydk] [debug] Trace: Writing message (session 34): 
<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <close-session/>
</rpc>

[2019-09-19 14:59:36.730] [ydk] [debug] Trace: Received message (session 34): 
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"><ok/></rpc-reply>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ydk_bundle_test is a Catch v1.7.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
test_augment_leaf
-------------------------------------------------------------------------------
/home/yan/ydk-workspace/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:337
...............................................................................

/home/yan/ydk-workspace/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:337: FAILED:
  {Unknown expression after the reported line}
due to unexpected exception with message:
  YServiceProviderError: Wrong payload! <xyz> not found

===============================================================================
test cases: 1 | 1 failed
assertions: 2 | 1 passed | 1 failed

System Information

@ygorelik ygorelik self-assigned this Sep 19, 2019
@ygorelik
Copy link
Collaborator Author

Similar issue observed in JsonSubtreeCodec.

ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant