Skip to content

Commit

Permalink
snmp: return error on unknown conversion type (influxdata#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
phemmer authored and sparrc committed Oct 6, 2016
1 parent 817d696 commit 5a86a2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ func (s *Snmp) getConnection(agent string) (snmpConnection, error) {
// "hwaddr" will convert the value into a MAC address.
// "ipaddr" will convert the value into into an IP address.
// "" will convert a byte slice into a string.
// Any other conv will return the input value unchanged.
func fieldConvert(conv string, v interface{}) (interface{}, error) {
if conv == "" {
if bs, ok := v.([]byte); ok {
Expand Down Expand Up @@ -805,6 +804,7 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) {
default:
return nil, fmt.Errorf("invalid type (%T) for hwaddr conversion", v)
}
return v, nil
}

if conv == "ipaddr" {
Expand All @@ -829,7 +829,7 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) {
return v, nil
}

return v, nil
return nil, fmt.Errorf("invalid conversion type '%s'", conv)
}

// snmpTranslate resolves the given OID.
Expand Down

0 comments on commit 5a86a2f

Please sign in to comment.