Skip to content

Commit

Permalink
fix: panic is no mibs folder is found (#10301)
Browse files Browse the repository at this point in the history
  • Loading branch information
MyaLongmire authored Dec 17, 2021
1 parent b672de3 commit e00147d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/snmp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func LoadMibsFromPath(paths []string, log telegraf.Logger) error {
appendPath(mibPath)
folders = append(folders, mibPath)
err := filepath.Walk(mibPath, func(path string, info os.FileInfo, err error) error {
if info == nil {
return fmt.Errorf("no mibs found")

This comment has been minimized.

Copy link
@helotpl

helotpl Dec 28, 2021

Contributor

Out of curiosity, why do you call fmt.Errorf when you have telegraf.Logger passed into LoadMibsFromPath as a parameter?

This comment has been minimized.

Copy link
@powersj

powersj Jan 4, 2022

Contributor

We are returning an error from this function and hence using fmt.Errorf to create the error to return. We do not want to only log the error and return nil as if an error never happened.

}
// symlinks are files so we need to double check if any of them are folders
// Will check file vs directory later on
if info.Mode()&os.ModeSymlink != 0 {
Expand Down

0 comments on commit e00147d

Please sign in to comment.