[processors.starlark] Error: NoneType has no .find field or method

I setup a telegraf agent to snmp query a Linux host using [inputs.snmp] plugin:
[[inputs.snmp.field]]
name = “sysDescr”
oid = “.1.3.6.1.2.1.1.1.0”
[[inputs.snmp.field]]
name = “root_filesystem_size_rhel7”
oid = “.1.3.6.1.2.1.25.2.3.1.5.52”
[[inputs.snmp.field]]
name = “root_filesystem_used_rhel7”
oid = “.1.3.6.1.2.1.25.2.3.1.6.52”

I added a [processors.starlark] plugin to process the data such as root filesystem size and usage before sending the data to InfluxDB. e.g.,
[[processors.starlark]]
namepass = [“snmp”]
source = ‘’’
def apply(metric):
linuxos = metric.fields.get(‘sysDescr’)
if linuxos.find(“el7”) != -1:
metric.fields[‘root_filesystem_size’] = metric.fields[‘root_filesystem_size_rhel7’]
metric.fields[‘root_filesystem_used’] = metric.fields[‘root_filesystem_used_rhel7’]
return metric
else:
return None
‘’’
I see the data is sent to InfluxDB and shown correctly in both field ‘root_filesystem_size’ and ‘root_filesystem_used’ in influxDB. However, the telegraf agent log file shows the following error messages:

2023-02-05T16:40:04Z E! [processors.starlark] Traceback (most recent call last):
2023-02-05T16:40:04Z E! [processors.starlark] processor.starlark:3:13: in apply
2023-02-05T16:40:04Z E! [processors.starlark] Error: NoneType has no .find field or method
2023-02-05T16:40:04Z E! [processors.starlark] Error in plugin: NoneType has no .find field or method

Any suggestion/comment on how to fix these errors?

Thanks in advance!