We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 and JsonSubtreeCodec fail decode empty type of data. They create empty leaf with value of empty string (expected: object Empty()).
Similar issue appears in JsonSubtreeCodec; see attached files for details.
json_codec_emty.cpp.txt json_ut.log
Add and run unit test:
TEST_CASE("xml_codec_empty") { auto repo = path::Repository{TEST_HOME}; std::vector<path::Capability> empty_caps; auto root = repo.create_root_schema(empty_caps); XmlSubtreeCodec xml_codec{}; // Encode auto runner = ydktest_sanity::Runner(); runner.ytypes->built_in_t->emptee = Empty(); auto xml = xml_codec.encode(runner, *root); string payload = R"(<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"> <ytypes> <built-in-t> <emptee/> </built-in-t> </ytypes> </runner>)"; CHECK(payload == xml); // Decode auto top_entity = make_shared<ydktest_sanity::Runner>(); auto entity = xml_codec.decode(payload, top_entity); auto runner_d = dynamic_cast<ydktest_sanity::Runner*>(entity.get()); CHECK(*runner_d == runner); }
Observe failure to compare entity Runner before and after encoding + decoding:
Runner
------------------------------------------------------------------------------- xml_codec_empty ------------------------------------------------------------------------------- /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:447 ............................................................................... /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:471: FAILED: CHECK( *runner_d == runner ) with expansion: {?} == {?} <runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"> <ytypes> <built-in-t> <emptee/> </built-in-t> </ytypes> </runner> =============================================================================== test cases: 1 | 1 failed assertions: 2 | 1 passed | 1 failed
When debug logging is enabled:
ygorelik$ ./ydk_bundle_test xml_codec_empty [2021-04-26 13:01:21.654] [ydk] [debug] Creating libyang context in path: /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/../core/tests/models [2021-04-26 13:01:21.655] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/libyang_ext_test.dylib" successfully loaded. [2021-04-26 13:01:21.656] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/metadata.dylib" successfully loaded. [2021-04-26 13:01:21.657] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/nacm.dylib" successfully loaded. [2021-04-26 13:01:21.657] [ydk] [debug] [libyang] Reading module "ietf-yang-metadata". [2021-04-26 13:01:21.657] [ydk] [debug] [libyang] Module "ietf-yang-metadata@2016-08-05" successfully parsed as implemented. [2021-04-26 13:01:21.657] [ydk] [debug] [libyang] Reading module "yang". [2021-04-26 13:01:21.657] [ydk] [debug] [libyang] Resolving "yang" unresolved schema nodes and their constraints... [2021-04-26 13:01:21.658] [ydk] [debug] [libyang] All "yang" schema nodes and constraints resolved. [2021-04-26 13:01:21.658] [ydk] [debug] [libyang] Module "yang@2017-02-20" successfully parsed as implemented. [2021-04-26 13:01:21.658] [ydk] [debug] [libyang] Reading module "ietf-inet-types". [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later. [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later. [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later. [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later. [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Resolving "ietf-inet-types" unresolved schema nodes and their constraints... [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] All "ietf-inet-types" schema nodes and constraints resolved. [2021-04-26 13:01:21.659] [ydk] [debug] [libyang] Module "ietf-inet-types@2013-07-15" successfully parsed as implemented. [2021-04-26 13:01:21.660] [ydk] [debug] [libyang] Reading module "ietf-yang-types". [2021-04-26 13:01:21.660] [ydk] [debug] [libyang] Module "ietf-yang-types@2013-07-15" successfully parsed as implemented. [2021-04-26 13:01:21.660] [ydk] [debug] [libyang] Reading module "ietf-datastores". [2021-04-26 13:01:21.661] [ydk] [debug] [libyang] Module "ietf-datastores@2017-08-17" successfully parsed as implemented. [2021-04-26 13:01:21.661] [ydk] [debug] [libyang] Reading module "ietf-yang-library". [2021-04-26 13:01:21.662] [ydk] [debug] [libyang] Module "ietf-yang-library@2017-08-17" successfully parsed as implemented. [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'ietf-yang-metadata' [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'yang' [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'ietf-inet-types' [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'ietf-yang-types' [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'ietf-datastores' [2021-04-26 13:01:21.662] [ydk] [debug] Populating new module schema 'ietf-yang-library' [2021-04-26 13:01:21.663] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner' [2021-04-26 13:01:21.663] [ydk] [debug] Loading module 'ydktest-sanity', revision '' [2021-04-26 13:01:21.663] [ydk] [debug] [libyang] Searching for "ydktest-sanity" in /Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models. [2021-04-26 13:01:21.663] [ydk] [debug] [libyang] Searching for "ydktest-sanity" in /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/build. [2021-04-26 13:01:21.663] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models/[email protected]" file. [2021-04-26 13:01:21.664] [ydk] [debug] [libyang] Searching for "ydktest-types" in /Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models. [2021-04-26 13:01:21.664] [ydk] [debug] [libyang] Searching for "ydktest-types" in /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/build. [2021-04-26 13:01:21.664] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models/[email protected]" file. [2021-04-26 13:01:21.665] [ydk] [debug] [libyang] Module "ydktest-types@2016-05-23" successfully parsed as implemented. [2021-04-26 13:01:21.665] [ydk] [debug] [libyang] Searching for "ydktest-sanity-submodule" in /Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models. [2021-04-26 13:01:21.665] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/github/ydk-gen/sdk/cpp/core/tests/models/[email protected]" file. [2021-04-26 13:01:21.666] [ydk] [debug] [libyang] Submodule "ydktest-sanity-submodule" successfully parsed. [2021-04-26 13:01:21.667] [ydk] [debug] [libyang] Resolving "ydktest-sanity" unresolved schema nodes and their constraints... [2021-04-26 13:01:21.668] [ydk] [debug] [libyang] All "ydktest-sanity" schema nodes and constraints resolved. [2021-04-26 13:01:21.668] [ydk] [debug] [libyang] Module "ydktest-sanity@2015-11-17" successfully parsed as implemented. [2021-04-26 13:01:21.668] [ydk] [debug] Added new libyang module 'ydktest-sanity' [2021-04-26 13:01:21.668] [ydk] [debug] Populating new module schema 'ydktest-sanity' [2021-04-26 13:01:21.668] [ydk] [debug] Looking to populate schemas for 'ydktest-sanity:runner' [2021-04-26 13:01:21.668] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner' [2021-04-26 13:01:21.668] [ydk] [debug] Loading module 'ydktest-sanity', revision '' [2021-04-26 13:01:21.668] [ydk] [debug] The module 'ydktest-sanity' schema has already been populated in YDK repository [2021-04-26 13:01:21.668] [ydk] [debug] Creating root data node with path '/ydktest-sanity:runner' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Leaf count: 0 [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Children count for: ydktest-sanity:runner : 14 [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'inbtw-list' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'leaf-ref' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'mtus' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'not-supported-1' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'one' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'one-list' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'one-read-only' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'outer' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'three' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'three-list' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'two' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'two-list' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'one' [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.669] [ydk] [debug] ================== [2021-04-26 13:01:21.669] [ydk] [debug] XMLCodec: Looking at child 'ytypes' [2021-04-26 13:01:21.669] [ydk] [debug] Looking to populate schemas for 'ytypes' [2021-04-26 13:01:21.669] [ydk] [debug] Getting new modules for path 'ytypes' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Leaf count: 0 [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Children count for: ytypes : 3 [2021-04-26 13:01:21.670] [ydk] [debug] ================== [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking at child 'built-in-t' [2021-04-26 13:01:21.670] [ydk] [debug] Looking to populate schemas for 'built-in-t' [2021-04-26 13:01:21.670] [ydk] [debug] Getting new modules for path 'built-in-t' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Leaf count: 1 [2021-04-26 13:01:21.670] [ydk] [debug] Looking to populate schemas for 'emptee' [2021-04-26 13:01:21.670] [ydk] [debug] Getting new modules for path 'emptee' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Creating child emptee of /ydktest-sanity:runner/all-ytypes-class/ytypes/built-in-t with value: '', is_set: true [2021-04-26 13:01:21.670] [ydk] [debug] XmlCodec: Creating leaf node 'emptee' with value: '' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Children count for: built-in-t : 0 [2021-04-26 13:01:21.670] [ydk] [debug] ================== [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking at child 'derived-t' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.670] [ydk] [debug] ================== [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking at child 'none' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking for child 'ytypes' in 'runner' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Creating child entity 'ytypes' in 'runner' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking for child 'built-in-t' in 'ytypes' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Creating child entity 'built-in-t' in 'ytypes' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Looking for child 'emptee' in 'built-in-t' [2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Creating leaf 'emptee' with no value ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ydk_bundle_test is a Catch v1.7.1 host application. Run with -? for options ------------------------------------------------------------------------------- xml_codec_empty ------------------------------------------------------------------------------- /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:447 ............................................................................... /Users/ygorelik/github/ydk-gen/sdk/cpp/tests/test_xml_subtree.cpp:471: FAILED: CHECK( *runner_d == runner ) with expansion: {?} == {?} [2021-04-26 13:01:21.670] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner' [2021-04-26 13:01:21.670] [ydk] [debug] Loading module 'ydktest-sanity', revision '' [2021-04-26 13:01:21.670] [ydk] [debug] The module 'ydktest-sanity' schema has already been populated in YDK repository [2021-04-26 13:01:21.670] [ydk] [debug] Looking to populate schemas for 'ydktest-sanity:runner' [2021-04-26 13:01:21.670] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner' [2021-04-26 13:01:21.671] [ydk] [debug] Loading module 'ydktest-sanity', revision '' [2021-04-26 13:01:21.671] [ydk] [debug] The module 'ydktest-sanity' schema has already been populated in YDK repository [2021-04-26 13:01:21.671] [ydk] [debug] Creating root data node with path '/ydktest-sanity:runner' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Leaf count: 0 [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Children count for: ydktest-sanity:runner : 14 [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'inbtw-list' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'leaf-ref' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'mtus' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'not-supported-1' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'one' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'one-list' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'one-read-only' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'outer' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'three' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'three-list' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'two' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'two-list' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'one' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'ytypes' [2021-04-26 13:01:21.671] [ydk] [debug] Looking to populate schemas for 'ytypes' [2021-04-26 13:01:21.671] [ydk] [debug] Getting new modules for path 'ytypes' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Leaf count: 0 [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Children count for: ytypes : 3 [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'built-in-t' [2021-04-26 13:01:21.671] [ydk] [debug] Looking to populate schemas for 'built-in-t' [2021-04-26 13:01:21.671] [ydk] [debug] Getting new modules for path 'built-in-t' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Leaf count: 1 [2021-04-26 13:01:21.671] [ydk] [debug] Looking to populate schemas for 'emptee' [2021-04-26 13:01:21.671] [ydk] [debug] Getting new modules for path 'emptee' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Creating child emptee of /ydktest-sanity:runner/all-ytypes-class/ytypes/built-in-t with value: '', is_set: false [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Storing operation 'read' for leaf emptee [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Children count for: built-in-t : 0 [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'derived-t' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations [2021-04-26 13:01:21.671] [ydk] [debug] ================== [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Looking at child 'none' [2021-04-26 13:01:21.671] [ydk] [debug] XMLCodec: Child has no data and no operations =============================================================================== test cases: 1 | 1 failed assertions: 2 | 1 passed | 1 failed
Important debug message shows that the leaf emptee was assigned empty string:
emptee
[2021-04-26 13:01:21.670] [ydk] [debug] XMLCodec: Creating child emptee of /ydktest-sanity:runner/all-ytypes-class/ytypes/built-in-t with value: '', is_set: true
YDK-0.8.5
The text was updated successfully, but these errors were encountered:
ygorelik
No branches or pull requests
Current Behavior
XmlSubtreeCodec and JsonSubtreeCodec fail decode empty type of data. They create empty leaf with value of empty string (expected: object Empty()).
Similar issue appears in JsonSubtreeCodec; see attached files for details.
json_codec_emty.cpp.txt
json_ut.log
How to reproduce
Add and run unit test:
Observe failure to compare entity
Runner
before and after encoding + decoding:Logs
When debug logging is enabled:
Important debug message shows that the leaf
emptee
was assigned empty string:System Information
YDK-0.8.5
The text was updated successfully, but these errors were encountered: