While manually running a pattern, the following message may appear: Error Message RuleError on rule tpl_CustomPattern_body_0 due to: Error while executing a rule -- AttributeError: 'NoneType' object has no attribute 'get' Pattern Name CustomPattern Error Count 1 Pattern CustomPattern Internal Error Details File "./__init__.py", line 770, in processEvent File "./rule.py", line 129, in doExecute File "/usr/tideway/var/code/generated_code/CustomPattern/__init__.py", line 1645, in execute if matches('(^edpp.*|^jspp.*|^epp.*|^jpp.*)', dict_get(llr_tpl_si_host, 'name')): File "./library.py", line 100, in dict_get How to diagnose / troubleshoot this? |
The important pieces of the error are highlighted below: Error Message RuleError on rule tpl_CustomPattern_body_0 due to: Error while executing a rule -- AttributeError: 'NoneType' object has no attribute 'get' Pattern Name CustomPattern Error Count 1 Pattern CustomPattern Internal Error Details File "./__init__.py", line 770, in processEvent File "./rule.py", line 129, in doExecute File "/usr/tideway/var/code/generated_code/CustomPattern/__init__.py", line 1645, in execute if matches('(^edpp.*|^jspp.*|^epp.*|^jpp.*)', dict_get(llr_tpl_si_host, 'name')): File "./library.py", line 100, in dict_get In this example, the customer has a pattern called "CustomPattern" Look in that pattern module, and find this string: si_host.name The error is: AttributeError: 'NoneType' object has no attribute 'get' This error means that "si_host" is not defined. It has a "none" value. Therefore, it cannot retrieve "name" from si_host. (The pattern should not refer to "si_host.name" when si_host is "none"). In this particular case, this error can only appear by using "Run Pattern", and pointing to a Manual Group of Software Instances (SI's). In this Manual Group, some of the SI's no longer have a related Host. (This may occur when aging the Host, but not the SI). When running a scan, this error cannot appear because by definition, any SI's that are being referred to during discovery do have a related host. The error can be fixed by adding the following highlighted statements before trying to retrieve an attribute from the "si_host" variable. si_host := model.host(si); if not si_host then stop(); end if; log.debug("si host = %si_host.name%"); |