Skip to content

Commit

Permalink
go.d fix dimension id check (netdata#18272)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored Aug 7, 2024
1 parent 25ca3cd commit c432b4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/go/plugin/go.d/agent/module/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func checkDim(d *Dim) error {
if d.ID == "" {
return errors.New("empty dim ID")
}
if id := checkID(d.ID); id != -1 {
if id := checkID(d.ID); id != -1 && (d.Name == "" || checkID(d.Name) != -1) {
return fmt.Errorf("unacceptable symbol in dim ID '%s' : '%c'", d.ID, id)
}
return nil
Expand Down
3 changes: 3 additions & 0 deletions src/go/plugin/go.d/agent/module/charts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ func TestDim_check(t *testing.T) {
dim = &Dim{ID: "id"}
dim.ID = "invalid id"
assert.Error(t, checkDim(dim))

dim = &Dim{ID: "i d", Name: "id"}
assert.NoError(t, checkDim(dim))
}

func TestVar_check(t *testing.T) {
Expand Down

0 comments on commit c432b4e

Please sign in to comment.