Skip to content

Go CodecService fails to encode leaf-list data #968

@ygorelik

Description

@ygorelik

Current Behavior

Go CodecService fails to encode leaf-list data.

Steps to Reproduce

Include this test to unit test suite in sanity_codec_test.go and run it.

func (suite *CodecTestSuite) TestLeafList() {
	runner := ysanity.Runner{}
	runner.Ytypes.BuiltInT.EnumLlist = append(runner.Ytypes.BuiltInT.EnumLlist, ysanity.YdkEnumTest_local)
	runner.Ytypes.BuiltInT.EnumLlist = append(runner.Ytypes.BuiltInT.EnumLlist, ysanity.YdkEnumTest_remote)

	payload := suite.Codec.Encode(&suite.Provider, &runner)
	fmt.Printf("%s\n", payload)
	runnerDecode := suite.Codec.Decode(&suite.Provider, payload)
	suite.True(types.EntityEqual(&runner, runnerDecode))
}

Run the script

$ go test -run CodecTestSuite/TestLeafList
CodecTestSuite: TestLeafList ...
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t/>
  </ytypes>
</runner>

Note that leaf-list data are not included to the payload

Logs

Enable logging and post the logs below

$ go test -run CodecTestSuite/TestLeafList -v
=== RUN   TestCodecTestSuite
=== RUN   TestCodecTestSuite/TestLeafList
CodecTestSuite: TestLeafList ...
[2019-11-19 10:42:41.167] [ydk] [debug] [Go] CodecServiceProvider initialized with ydktest bundle
[2019-11-19 10:42:41.167] [ydk] [debug] [Go] CodecServiceProvider using YANG models in /Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang
[2019-11-19 10:42:41.168] [ydk] [debug] Creating libyang context in path: /Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang
[2019-11-19 10:42:41.168] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/libyang_ext_test.dylib" successfully loaded.
[2019-11-19 10:42:41.169] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/metadata.dylib" successfully loaded.
[2019-11-19 10:42:41.169] [ydk] [debug] [libyang] Extension plugin "/usr/local/lib/libyang/nacm.dylib" successfully loaded.
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] Reading module "ietf-yang-metadata".
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] Module "ietf-yang-metadata@2016-08-05" successfully parsed as implemented.
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] Reading module "yang".
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] Resolving "yang" unresolved schema nodes and their constraints...
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] All "yang" schema nodes and constraints resolved.
[2019-11-19 10:42:41.170] [ydk] [debug] [libyang] Module "yang@2017-02-20" successfully parsed as implemented.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Reading module "ietf-inet-types".
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Resolving derived type "union" failed, it will be attempted later.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Resolving "ietf-inet-types" unresolved schema nodes and their constraints...
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] All "ietf-inet-types" schema nodes and constraints resolved.
[2019-11-19 10:42:41.171] [ydk] [debug] [libyang] Module "ietf-inet-types@2013-07-15" successfully parsed as implemented.
[2019-11-19 10:42:41.172] [ydk] [debug] [libyang] Reading module "ietf-yang-types".
[2019-11-19 10:42:41.172] [ydk] [debug] [libyang] Module "ietf-yang-types@2013-07-15" successfully parsed as implemented.
[2019-11-19 10:42:41.172] [ydk] [debug] [libyang] Reading module "ietf-datastores".
[2019-11-19 10:42:41.172] [ydk] [debug] [libyang] Module "ietf-datastores@2017-08-17" successfully parsed as implemented.
[2019-11-19 10:42:41.173] [ydk] [debug] [libyang] Reading module "ietf-yang-library".
[2019-11-19 10:42:41.173] [ydk] [debug] [libyang] Module "ietf-yang-library@2017-08-17" successfully parsed as implemented.
[2019-11-19 10:42:41.173] [ydk] [debug] Populating new module schema 'ietf-yang-metadata'
[2019-11-19 10:42:41.174] [ydk] [debug] Populating new module schema 'yang'
[2019-11-19 10:42:41.174] [ydk] [debug] Populating new module schema 'ietf-inet-types'
[2019-11-19 10:42:41.174] [ydk] [debug] Populating new module schema 'ietf-yang-types'
[2019-11-19 10:42:41.174] [ydk] [debug] Populating new module schema 'ietf-datastores'
[2019-11-19 10:42:41.174] [ydk] [debug] Populating new module schema 'ietf-yang-library'
[2019-11-19 10:42:41.174] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner'
[2019-11-19 10:42:41.174] [ydk] [debug] Loading module 'ydktest-sanity', revision ''
[2019-11-19 10:42:41.174] [ydk] [debug] [libyang] Searching for "ydktest-sanity" in /Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang.
[2019-11-19 10:42:41.174] [ydk] [debug] [libyang] Searching for "ydktest-sanity" in /Users/ygorelik/ydk-gen/sdk/go/core/tests.
[2019-11-19 10:42:41.174] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang/ydktest-sanity@2015-11-17.yang" file.
[2019-11-19 10:42:41.175] [ydk] [debug] [libyang] Searching for "ydktest-types" in /Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang.
[2019-11-19 10:42:41.175] [ydk] [debug] [libyang] Searching for "ydktest-types" in /Users/ygorelik/ydk-gen/sdk/go/core/tests.
[2019-11-19 10:42:41.175] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang/ydktest-types@2016-05-23.yang" file.
[2019-11-19 10:42:41.175] [ydk] [debug] [libyang] Module "ydktest-types@2016-05-23" successfully parsed as implemented.
[2019-11-19 10:42:41.175] [ydk] [debug] [libyang] Searching for "ydktest-sanity-submodule" in /Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang.
[2019-11-19 10:42:41.176] [ydk] [debug] [libyang] Loading schema from "/Users/ygorelik/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/_yang/ydktest-sanity-submodule@2016-04-25.yang" file.
[2019-11-19 10:42:41.176] [ydk] [debug] [libyang] Submodule "ydktest-sanity-submodule" successfully parsed.
[2019-11-19 10:42:41.177] [ydk] [debug] [libyang] Resolving "ydktest-sanity" unresolved schema nodes and their constraints...
[2019-11-19 10:42:41.178] [ydk] [debug] [libyang] All "ydktest-sanity" schema nodes and constraints resolved.
[2019-11-19 10:42:41.178] [ydk] [debug] [libyang] Module "ydktest-sanity@2015-11-17" successfully parsed as implemented.
[2019-11-19 10:42:41.178] [ydk] [debug] Added new libyang module 'ydktest-sanity'
[2019-11-19 10:42:41.178] [ydk] [debug] Populating new module schema 'ydktest-sanity'
[2019-11-19 10:42:41.178] [ydk] [debug] Looking to populate schemas for 'ydktest-sanity:runner'
[2019-11-19 10:42:41.178] [ydk] [debug] Getting new modules for path 'ydktest-sanity:runner'
[2019-11-19 10:42:41.178] [ydk] [debug] Loading module 'ydktest-sanity', revision ''
[2019-11-19 10:42:41.178] [ydk] [debug] The module 'ydktest-sanity' schema has already been populated in YDK repository
[2019-11-19 10:42:41.178] [ydk] [debug] Creating root data node with path '/ydktest-sanity:runner'
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] path.getDataNodeFromEntity: Created datanode with path 'ydktest-sanity:runner'
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] Got 23 entity children
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] Looking at entity child 'one'
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] Looking at entity child 'two'
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] Looking at entity child 'three'
[2019-11-19 10:42:41.178] [ydk] [debug] [Go] Looking at entity child 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Populating schema for 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Looking to populate schemas for 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting new modules for path 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Creating node 'ytypes' with value ''
[2019-11-19 10:42:41.179] [ydk] [debug] Current path: /ydktest-sanity:runner
[2019-11-19 10:42:41.179] [ydk] [debug] Top container path: ydktest-sanity:runner
[2019-11-19 10:42:41.179] [ydk] [debug] Populating schema for 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Looking to populate schemas for 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting new modules for path 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting child schema with path 'ytypes' in /ydktest-sanity:runner
[2019-11-19 10:42:41.179] [ydk] [debug] Getting data nodes with path 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] Creating new data path 'ytypes' with value '' in 'runner'
[2019-11-19 10:42:41.179] [ydk] [debug] [Go] path.populateDataNode: Populating leafs in datanode with path 'ydktest-sanity:runner/ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] [Go] Got 3 entity children
[2019-11-19 10:42:41.179] [ydk] [debug] [Go] Looking at entity child 'none'
[2019-11-19 10:42:41.179] [ydk] [debug] [Go] Looking at entity child 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Populating schema for 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Looking to populate schemas for 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting new modules for path 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Creating node 'built-in-t' with value ''
[2019-11-19 10:42:41.179] [ydk] [debug] Current path: /ydktest-sanity:runner/ytypes
[2019-11-19 10:42:41.179] [ydk] [debug] Top container path: ydktest-sanity:runner
[2019-11-19 10:42:41.179] [ydk] [debug] Populating schema for 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Looking to populate schemas for 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting new modules for path 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Getting child schema with path 'built-in-t' in /ydktest-sanity:runner/ytypes
[2019-11-19 10:42:41.179] [ydk] [debug] Getting data nodes with path 'built-in-t'
[2019-11-19 10:42:41.179] [ydk] [debug] Creating new data path 'built-in-t' with value '' in 'ytypes'
[2019-11-19 10:42:41.179] [ydk] [debug] [Go] path.populateDataNode: Populating leafs in datanode with path 'ydktest-sanity:runner/ytypes/built-in-t'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Got 0 entity children
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] 
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'derived-t'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] 
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'one-list'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'two-list'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'three-list'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'inbtw-list'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'leaf-ref'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'not-supported-1'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'one-read-only'
[2019-11-19 10:42:41.180] [ydk] [debug] [Go] Looking at entity child 'mtus'
[2019-11-19 10:42:41.181] [ydk] [debug] [Go] Looking at entity child 'outer'
[2019-11-19 10:42:41.181] [ydk] [debug] [Go] Looking at entity child 'runner-2'
[2019-11-19 10:42:41.181] [ydk] [debug] [Go] Looking at entity child 'ydktest-sanity-augm:one'
[2019-11-19 10:42:41.181] [ydk] [debug] [Go] 
[2019-11-19 10:42:41.181] [ydk] [debug] ydk::path::Codec: Encoding data node '/ydktest-sanity:runner' to XML formated string
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t/>
  </ytypes>
</runner>

[2019-11-19 10:42:41.181] [ydk] [debug] [Go] services.getEntityLookupKey: Using XML encoding for payload:
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t/>
  </ytypes>
</runner>

[2019-11-19 10:42:41.181] [ydk] [debug] [Go] services.getEntityLookupKey: Got namespace: '{http://cisco.com/ns/yang/ydktest-sanity runner}'
[2019-11-19 10:42:41.181] [ydk] [debug] ydk::path::Codec: Decoding from XML formatted payload:
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t/>
  </ytypes>
</runner>

[2019-11-19 10:42:41.181] [ydk] [debug] Populating new schema from payload:
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t/>
  </ytypes>
</runner>

[2019-11-19 10:42:41.181] [ydk] [debug] Extracting module namespaces from XML payload
[2019-11-19 10:42:41.181] [ydk] [debug] Loading module 'ydktest-sanity', revision ''
[2019-11-19 10:42:41.181] [ydk] [debug] The module 'ydktest-sanity' schema has already been populated in YDK repository
[2019-11-19 10:42:41.182] [ydk] [debug] Performing decode operation
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.CodecServiceDecode: Top entity path: 'ydktest-sanity:runner'; Number of children in datanode: '1'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.CodecServiceDecode: Getting entity from single datanode
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.ReadDatanode: Number of entities in the filter: 1
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.getEntityFromDataNode: Got 1 children in datanode 'runner'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] Looking at child datanode: 'ytypes'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] Creating child entity 'ytypes'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.getEntityFromDataNode: Got 1 children in datanode 'ytypes'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] Looking at child datanode: 'built-in-t'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] Creating child entity 'built-in-t'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.getEntityFromDataNode: Got 0 children in datanode 'built-in-t'
[2019-11-19 10:42:41.182] [ydk] [debug] [Go] path.ReadDatanode: Number of entities returning: 1, filter is EC: false
--- PASS: TestCodecTestSuite (0.02s)
    --- PASS: TestCodecTestSuite/TestLeafList (0.02s)
PASS
ok  	_/Users/ygorelik/ydk-gen/sdk/go/core/tests	0.043s

System Information

YDK-0.8.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions