openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
284 stars 106 forks source link

ygot Validate error, when yang leaf type is union #949

Open songlinglingpml opened 8 months ago

songlinglingpml commented 8 months ago

I am using openconfig/ygotv0.7.1 , Validate funtion When I use restful to send delete messages, sometimes the following error occurs

URL: restconf/data/openconfig-network-instance:network-instances/network-instance=DEFAULT/protocols/protocol=oc-pol-types:ISIS,DEFAULT/isis/interfaces/interface=Ethernet8/levels/level=2/afi-safi/af=oc-isis-types:IPV4,oc-isis-types:UNICAST/segment-routing/adjacency-sids/adjacency-sid=172.60.61.1,321536

Code: baseTreeNode, err := ytypes.GetNode(ygSchema.RootSchema(), deviceObj, path) basePathObj, ok := (baseTreeNode[0].Data).(ygot.ValidatedGoStruct) if ok { err := basePathObj.Validate(&ytypes.LeafrefOptions{IgnoreMissingData: true}) ......

error-message "/device/network-instances/network-instance: /device/network-instances/network-instance/protocols/protocol: /device/network-instances/network-instance/protocols/protocol/isis/interfaces: /device/network-instances/network-instance/protocols/protocol/isis/interfaces/interface: /device/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level: /device/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af: /device/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af/segment-routing/adjacency-sids: /device/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af/segment-routing/adjacency-sids/adjacency-sid: \"321536\" does not match regular expression pattern \"^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$\" for schema "

yang info: sid-id is in openconfig-segment-routing.yang,and it's type union

leaf sid-id {
  type oc-srt:sr-sid-type;
  description
    "The Segment Identifier to be used when advertising the IGP Prefix SID.";
}

typedef sr-sid-type { type union { type oc-mplst:mpls-label; ===》openconfig-mpls-types.yang type oc-inet:ipv6-address; ===》openconfig-inet-types.yang } description "The defined value of a segment identifier."; }

Is this a known issue?