# Buggy code
def get_tags_for_dynamic_obj(self, mid=None, type=None):
    """
    Return list of tag object details associated with object
    Args:
        mid: Dynamic object for specified object
        type: Type of DynamicID to lookup

    Returns: List of tag object details associated with the given object

    """
    tags = []
    if mid is None:
        return tags
    dynamic_managed_object = DynamicID(type=type, id=mid)

    temp_tags_model = self.get_tags_for_object(dynamic_managed_object)

    category_service = self.api_client.tagging.Category

    for tag_obj in temp_tags_model:
        tags.append(
            {
                "id": tag_obj.id,
                "category_name": category_service.get(tag_obj.category_id).name,
                "name": tag_obj.name,
                "description": tag_obj.description,
                "category_id": tag_obj.category_id,
            }
        )

    return tags


# Traceback (nTypeError)
<localhost> Attempting python interpreter discovery
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: dpelliccia
<localhost> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"';                      command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; comma                     nd -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND &amp;&amp; sl                     eep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python &amp;&amp; sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/_vmware_vm_facts.py
Pipelining is enabled.
<localhost> EXEC /bin/sh -c '/usr/bin/python &amp;&amp; sleep 0'
fatal: [localhost -> localhost]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS reques                     t is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.ht                     ml#ssl-warnings\n  InsecureRequestWarning)\nTraceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<                     stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib64/python2.7/runpy.py\", line                      180, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in r                     un_globals\n  File \"/tmp/ansible_vmware_vm_facts_payload_x51H8H/ansible_vmware_vm_facts_payload.zip/ansible/modules/cloud/vmware/_vm                     ware_vm_facts.py\", line 322, in <module>\n  File \"/tmp/ansible_vmware_vm_facts_payload_x51H8H/ansible_vmware_vm_facts_payload.zip/a                     nsible/modules/cloud/vmware/_vmware_vm_facts.py\", line 316, in main\n  File \"/tmp/ansible_vmware_vm_facts_payload_x51H8H/ansible_vm                     ware_vm_facts_payload.zip/ansible/modules/cloud/vmware/_vmware_vm_facts.py\", line 272, in get_all_virtual_machines\n  File \"/tmp/an                     sible_vmware_vm_facts_payload_x51H8H/ansible_vmware_vm_facts_payload.zip/ansible/modules/cloud/vmware/_vmware_vm_facts.py\", line 208                     , in get_tag_info\nTypeError: get_tags_for_vm() got an unexpected keyword argument 'vm_id'\n/usr/lib/python2.7/site-packages/urllib3/                     connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly ad                     vised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

# Fixed code
def get_tags_for_dynamic_obj(self, mid=None):
    """
    Return list of tag object details associated with object
    Args:
        mid: Dynamic object for specified object

    Returns: List of tag object details associated with the given object

    """
    tags = []
    if mid is None:
        return tags

    temp_tags_model = self.get_tags_for_object(dobj=mid)

    category_service = self.api_client.tagging.Category

    for tag_obj in temp_tags_model:
        tags.append(
            {
                "id": tag_obj.id,
                "category_name": category_service.get(tag_obj.category_id).name,
                "name": tag_obj.name,
                "description": tag_obj.description,
                "category_id": tag_obj.category_id,
            }
        )

    return tags