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

proto_generator may generate duplicate messages with package_hierarchy=true #794

Open
tokarenko opened this issue Mar 16, 2023 · 0 comments

Comments

@tokarenko
Copy link

Issue description

proto_generator incorrectly processes IETF interfaces YANG model and generates duplicate InterfaceKey message at top-level ietf_interfaces.proto.

Steps to reproduce:

  1. Launch proto_generator as follows:
    proto_generator -output_dir=./proto -package_hierarchy=true [email protected] [email protected]

  2. Obtain unexpected duplicate InterfaceKey message in generation result in ./proto/openconfig/ietf_interfaces/ietf_interfaces.proto

// openconfig.ietf_interfaces is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
//  - [email protected]
//  - [email protected]
syntax = "proto3";

package openconfig.ietf_interfaces;

import "github.com/openconfig/ygot/proto/yext/yext.proto";
import "openconfig/ietf_interfaces/interfaces/interfaces.proto";
import "openconfig/ietf_interfaces/interfaces_state/interfaces_state.proto";

// InterfaceKey represents the /ietf-interfaces/interfaces/interface YANG schema element.
message InterfaceKey {
  string name = 1 [(yext.schemapath) = "/interfaces/interface/name"];
  interfaces.Interface interface = 2;
}

// Interfaces represents the /ietf-interfaces/interfaces YANG schema element.
message Interfaces {
  repeated InterfaceKey interface = 398263028 [(yext.schemapath) = "/interfaces/interface"];
}

// InterfaceKey represents the /ietf-interfaces/interfaces-state/interface YANG schema element.
message InterfaceKey {
  string name = 1 [(yext.schemapath) = "/interfaces-state/interface/name"];
  interfaces_state.Interface interface = 2;
}

// InterfacesState represents the /ietf-interfaces/interfaces-state YANG schema element.
message InterfacesState {
  repeated InterfaceKey interface = 199470812 [(yext.schemapath) = "/interfaces-state/interface"];
}

Expected result

Expected result is that InterfaceKey is not duplicated.
proto_generator works as expected with nested messages (without -package_hierarchy=true).

message Interfaces {
  message Interface { 
    ...
  }
  message InterfaceKey {
    string name = 1 [(yext.schemapath) = "/interfaces/interface/name"];
    Interface interface = 2;
}
  repeated InterfaceKey interface = 398263028 [(yext.schemapath) = "/interfaces/interface"];
}

message InterfacesState {
  message Interface { ...
    ...
}
  message InterfaceKey {
    string name = 1 [(yext.schemapath) = "/interfaces-state/interface/name"];
    Interface interface = 2;
  }
  repeated InterfaceKey interface = 199470812 [(yext.schemapath) = "/interfaces-state/interface"];
}

Supplementary information

Contents of [email protected]

  container interfaces {
    description
      "Interface parameters.";

    list interface {
      key "name";

...

  container interfaces-state {
    config false;
    status deprecated;
    description
      "Data nodes for the operational state of interfaces.";

    list interface {
      key "name";
      status deprecated;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant