[YANGTOOLS-766] yang-data-codec-gson: compressed instance-identifier codec Created: 27/Mar/17 Updated: 10/Apr/22 Resolved: 28/Dec/17 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 2.0.0, 1.2.1 |
| Fix Version/s: | 1.2.2, 2.0.1 |
| Type: | Bug | ||
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| External issue ID: | 8083 | ||||||||||||||||||||||||||||||||
| Description |
|
There is a slight difference between how instance-identifiers are encoded in https://tools.ietf.org/html/draft-lhotka-netmod-yang-json-02 (used by draft-bierman-netconf-restconf-02) and https://tools.ietf.org/html/rfc7951 (used by RFC8040). For RFC8040 we need to use a different JSON codec to handle prefixes. While we are in the area, I suspect key encoding does not work correctly (for both XML and JSON) with respect to complex types – i.e. when we are encoding an instance identifier which uses one of:
|
| Comments |
| Comment by Igor Foltin [ 30/Mar/17 ] |
|
I wrote a bunch of unit tests - https://git.opendaylight.org/gerrit/#/c/54106/ JSON parsing: Currently, an instance-identifier value must have all its node-identifiers prefixed to be parsed without failing. Thus, if we want to follow the rules defined in RFC7951, we'll have to modify the JSON instance-identifier codec so that values like this can be parsed: An instance-identifier which has a list with a key of type empty in its path - this does not work because the key value (in JSON it's [null]) is deserialized to null which leads to a NPE when inserting it into a key-value map here: XpathStringParsingPathArgumentBuilder.java:166 An instance-identifier which has a list with a key of type identityref in its path - this works whether the key value contains a prefix or not. An instance-identifier which has a list with a key of type instance-identifier in its path - this works only when the key value contains prefixes. XML parsing: An instance-identifier which has a list with a key of type empty in its path - this does not work because the key value (in XML it's an empty/self-closed element) is deserialized to null which leads to a NPE when inserting it into key-value map here: XpathStringParsingPathArgumentBuilder.java:166 An instance-identifier which has a list with a key of type identityref in its path - this works whether the key value contains a prefix or not. An instance-identifier which has a list with a key of type instance-identifier in its path - this works only when the key value contains prefixes. |
| Comment by Robert Varga [ 26/Dec/17 ] |
|
Since the above analysis was done we have moved a bit. empty leaves are now properly represented with a non-null Empty object, allowing them to be used in keys.
This leaves this issue to deal with the original problem, which is YangInstanceIdentifier parsing/emission without repeating prefixes. The JSON parser API change to enable users to select proper JSONCodecFactory is at https://git.opendaylight.org/gerrit/66765. |
| Comment by Robert Varga [ 26/Dec/17 ] |
|
As it turns out, this issue affects both parsing and emission of YangInstanceIdentifier, as RFC7951 explicitly forbids the use of prefixes when the subsequent node identifier has the same namespace. |
| Comment by Robert Varga [ 26/Dec/17 ] |
|
At any rate, the next step is to wire a slightly different version of XpathStringParsingPathArgumentBuilder into RFC7951, one that is memoizing last used prefix (or even resulting QNameModule) when parsing an argument, but not when parsing predicates. |
| Comment by Robert Varga [ 27/Dec/17 ] |
|
Support for parsing RFC7951 instance identifiers: https://git.opendaylight.org/gerrit/66772 |
| Comment by Robert Varga [ 27/Dec/17 ] |
|
Nitrogen cherry-picks: https://git.opendaylight.org/gerrit/66773 https://git.opendaylight.org/gerrit/66774
|