JSON encoding not supported for leaf-nodes
- Dominant language
- Python
- Stars
- 289
- Forks
- 131
- Avg merge
- 1d 28m
- Merged PRs (30d)
- 1
Description
Hi,
**1. I have problem to set leaf node with with json_val.**
sending update request:
```
update {
path {
elem {
name: "system"
}
elem {
name: "config"
}
elem {
name: "domain-name"
}
}
val {
json_val: "domain-name.com"
}
}
```
returns error: `INTERNAL: cannot convert leaf node to scalar type: non-scalar type &{JsonVal:[100 111 109 97 105 110 45 110 97 109 101 46 99 111 109]}`
The specification tells that the value node should be encoded by `oneof` the scalar types or structural types ... .
Also in the [2.3.1 JSON and JSON_IETF](https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#231-json-and-json_ietf) there is example how `string` or `uint32` `leaf-node` can be serialized.
So I think the server should be able to apply also scalar type
```
val {
string_val: "domain-name.com"
}
```
but also JSON type
```
val {
json_val: "domain-name.com"
}
```
**2. Also the server does not return json_val for leaf-nodes.**
When the encoding is explicitly specified in get request:
```
path {
elem {
name: "system"
}
elem {
name: "config"
}
elem {
name: "domain-name"
}
}
encoding: JSON_IETF
```
It returns val as `string_val`. I would expect `json_val`.
```
notification {
timestamp: 1532431023993295089
update {
path {
elem {
name: "system"
}
elem {
name: "config"
}
elem {
name: "domain-name"
}
}
val {
string_val: "domain-name.com"
}
}
}
```
Same response returned even when encoding is not specified.
The [specification](https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#32-capability-discovery) tells that `If the client does not specify the encoding in an RPC message, it MUST send JSON encoded values (the default encoding)`. So I would expect to get at least `json_val` also when no encoding was specified.
Or did I understand it wrong? Please correct me if so.
Contributor guide
Assessment
This issue has not been assessed yet.