Skip to content
New issue

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

JSON encoding not supported for leaf-nodes #31

Open
vainyksi opened this issue Jul 24, 2018 · 1 comment
Open

JSON encoding not supported for leaf-nodes #31

vainyksi opened this issue Jul 24, 2018 · 1 comment
Labels
clarify Needs further clarification gnmi

Comments

@vainyksi
Copy link

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 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 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.

@samribeiro samribeiro added the clarify Needs further clarification label Jul 8, 2020
@xavier-contreras
Copy link
Contributor

Just ran into this using json_ietf_val when updating a single leaf node (had to use string_val).

Perhaps this can be explained by https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#223-node-values which does not explicitly list json or json_ietf_val as possible options but it does mention it must be a TypedValue which the proto definition does have in the oneof: https://github.com/openconfig/gnmi/blob/5473f2ef722ee45c3f26eee3f4a44a7d827e3575/proto/gnmi/gnmi.proto#L108

So it's not clear IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarify Needs further clarification gnmi
Projects
None yet
Development

No branches or pull requests

3 participants