Discovery: How to diagnose RuleError on a pattern: rule tpl_CustomPattern_body_0 due to: Error while executing a rule -- AttributeError: 'NoneType' object has no attribute 'get'

Version 1
    Share This:

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    BMC Discovery


    COMPONENT:

    BMC Discovery 11.3


    APPLIES TO:

    BMC Discovery



    QUESTION:

    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?
     


    ANSWER:

    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%");



     


    Article Number:

    000135762


    Article Type:

    FAQ/Procedural



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles