{"action":"closed","issue":{"url":"https://api.github.com/repos/CESNET/libyang/issues/205","repository_url":"https://api.github.com/repos/CESNET/libyang","labels_url":"https://api.github.com/repos/CESNET/libyang/issues/205/labels{/name}","comments_url":"https://api.github.com/repos/CESNET/libyang/issues/205/comments","events_url":"https://api.github.com/repos/CESNET/libyang/issues/205/events","html_url":"https://github.com/CESNET/libyang/issues/205","id":191111390,"number":205,"title":"List keys are expected to be the first siblings, and in order","user":{"login":"p-jean","id":11744961,"avatar_url":"https://avatars.githubusercontent.com/u/11744961?v=3","gravatar_id":"","url":"https://api.github.com/users/p-jean","html_url":"https://github.com/p-jean","followers_url":"https://api.github.com/users/p-jean/followers","following_url":"https://api.github.com/users/p-jean/following{/other_user}","gists_url":"https://api.github.com/users/p-jean/gists{/gist_id}","starred_url":"https://api.github.com/users/p-jean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p-jean/subscriptions","organizations_url":"https://api.github.com/users/p-jean/orgs","repos_url":"https://api.github.com/users/p-jean/repos","events_url":"https://api.github.com/users/p-jean/events{/privacy}","received_events_url":"https://api.github.com/users/p-jean/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-22T20:08:10Z","updated_at":"2016-11-22T22:44:49Z","closed_at":"2016-11-22T22:44:49Z","body":"The function lyv_keys(), for example, expects the leaf objects for the keys to be the first siblings, and in the same order as the schema->keys[] array. If the keys are not defined in yang/yin to be the first leaves in the list, then validation fails. The Yang specification does not appear to put a limitation on the placement or order of keys in the yang definition, though the XML encoding does specify an order. \r\n\r\nUsing lyd_sort() does not help in this case, because the leaves are sorted in the order as given by the yang/yin model (and keys not always in first slots).\r\n\r\nAs an illustration, consider the (valid?) list definition:\r\n`\r\nlist l {\r\n\tkey \"d b\";\r\n\tleaf a {\r\n\t}\r\n\tleaf b {\r\n\t}\r\n\tleaf c {\r\n\t}\r\n\tleaf d {\r\n\t}\r\n}\r\n`\r\nThe schema siblings will be [ a, b, c, d ] but the schema keys will be [ d, b ] which will fail to match in lyv_keys().\r\n\r\nThe XML encoding requires the keys to be first and in order, so it would need to be [ d, b, a, c ] or [ d, b, c, a ]\r\n\r\nIt seems like a good style to define the keys in order at the beginning of a list, however I inherited a model translated from a legacy system which does not have that restriction. The quick workaround is to re-order the yang definitions (if possible).\r\n\r\n"}}
{"actor":{"display_login":"rkrejci"}}