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
…y. (#10188)

(cherry picked from commit aa642a4)
  • Loading branch information
srebhan authored and sspaink committed Dec 15, 2021
1 parent 99c0b23 commit a4debb1
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 a4debb1

Please sign in to comment.