1515package pluginrpc
1616
1717import (
18+ "errors"
1819 "slices"
1920
2021 pluginrpcv1 "buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go/pluginrpc/v1"
@@ -32,6 +33,8 @@ type Spec interface {
3233 // If no such procedure exists, this returns nil.
3334 ProcedureForPath (path string ) Procedure
3435 // Procedures returns all Procedures.
36+ //
37+ // Never empty.
3538 Procedures () []Procedure
3639
3740 isSpec ()
@@ -69,10 +72,16 @@ func NewProtoSpec(spec Spec) *pluginrpcv1.Spec {
6972
7073// MergeSpecs merges the given Specs.
7174//
75+ // Input Specs can be nil. If all input Specs are nil, an error is returned
76+ // as Specs must have at least one Procedure..
77+ //
7278// Returns error if any Procedures overlap by Path or Args.
7379func MergeSpecs (specs ... Spec ) (Spec , error ) {
7480 var procedures []Procedure
7581 for _ , spec := range specs {
82+ if spec == nil {
83+ continue
84+ }
7685 procedures = append (procedures , spec .Procedures ()... )
7786 }
7887 return NewSpec (procedures ... )
@@ -86,6 +95,9 @@ type spec struct {
8695}
8796
8897func newSpec (procedures []Procedure ) (* spec , error ) {
98+ if len (procedures ) == 0 {
99+ return nil , errors .New ("no procedures specified" )
100+ }
89101 if err := validateProcedures (procedures ); err != nil {
90102 return nil , err
91103 }
0 commit comments