Skip to content

Commit

Permalink
fix: Handle duplicate registration of protocol-buffer files gracefull…
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan authored and powersj committed Jan 21, 2022
1 parent 57ca11a commit 99b558f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/parsers/xpath/protocolbuffer_document.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xpath

import (
"errors"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -55,6 +56,13 @@ func (d *protobufDocument) Init() error {
if err != nil {
return fmt.Errorf("creating file descriptor from proto failed: %v", err)
}
if _, err := protoregistry.GlobalFiles.FindFileByPath(fileDesc.Path()); !errors.Is(err, protoregistry.NotFound) {
if err != nil {
return fmt.Errorf("searching for file %q in registry failed: %v", fileDesc.Path(), err)
}
d.Log.Warnf("Protocol buffer with path %q already registered. Skipping...", fileDesc.Path())
continue
}
if err := protoregistry.GlobalFiles.RegisterFile(fileDesc); err != nil {
return fmt.Errorf("registering file descriptor %q failed: %v", fileDesc.Package(), err)
}
Expand Down

0 comments on commit 99b558f

Please sign in to comment.