Skip to content

Commit

Permalink
Clarify error message when connector ID must be disambiguated (#8121)
Browse files Browse the repository at this point in the history
Resolves #8120
  • Loading branch information
djaglowski committed Jul 21, 2023
1 parent 89f1e9f commit a18c67d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions otelcol/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ func (cfg *Config) Validate() error {
}

if _, ok := cfg.Exporters[connID]; ok {
return fmt.Errorf("connectors::%s: there's already an exporter named %q", connID, connID)
return fmt.Errorf("connectors::%s: ambiguous ID: Found both %q exporter and %q connector. "+
"Change one of the components' IDs to eliminate ambiguity (e.g. rename %q connector to %q)",
connID, connID, connID, connID, connID.String()+"/connector")
}
if _, ok := cfg.Receivers[connID]; ok {
return fmt.Errorf("connectors::%s: there's already a receiver named %q", connID, connID)
return fmt.Errorf("connectors::%s: ambiguous ID: Found both %q receiver and %q connector. "+
"Change one of the components' IDs to eliminate ambiguity (e.g. rename %q connector to %q)",
connID, connID, connID, connID, connID.String()+"/connector")
}
}

Expand Down
4 changes: 2 additions & 2 deletions otelcol/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestConfigValidate(t *testing.T) {
pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "2"))
return cfg
},
expected: errors.New(`connectors::nop/2: there's already a receiver named "nop/2"`),
expected: errors.New(`connectors::nop/2: ambiguous ID: Found both "nop/2" receiver and "nop/2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop/2" connector to "nop/2/connector")`),
},
{
name: "ambiguous-connector-name-as-exporter",
Expand All @@ -190,7 +190,7 @@ func TestConfigValidate(t *testing.T) {
pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "2"))
return cfg
},
expected: errors.New(`connectors::nop/2: there's already an exporter named "nop/2"`),
expected: errors.New(`connectors::nop/2: ambiguous ID: Found both "nop/2" exporter and "nop/2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop/2" connector to "nop/2/connector")`),
},
{
name: "invalid-connector-reference-as-receiver",
Expand Down

0 comments on commit a18c67d

Please sign in to comment.