# Buggy code
def _populate_from_cache(self, source_data):
    """
    Populate inventory from cache
    """
    hostvars = source_data.pop("_meta", {}).get("hostvars", {})
    for group in source_data:
        if group == "all":
            continue
        else:
            self.inventory.add_group(group)
            self.inventory.add_child("all", group)
    if not source_data:
        for host in hostvars:
            self.inventory.add_host(host)


# Traceback (RepresenterError)
ansible-inventory --list --yaml -i inventory.vmware.yml -vvvv
ansible-inventory 2.7.7
config file = /mnt/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible-inventory
python version = 2.7.15 (default, Feb  6 2019, 12:35:55) [GCC 6.3.0 20170516]
Using /mnt/ansible/ansible.cfg as config file
setting up inventory plugins
/mnt/ansible/inventory.vmware.yml did not meet host_list requirements, check plugin documentation if this is unexpected
/mnt/ansible/inventory.vmware.yml did not meet script requirements, check plugin documentation if this is unexpected
Parsed /mnt/ansible/inventory.vmware.yml inventory source with auto plugin
ERROR! Unexpected Exception, this is probably a bug: cannot represent an object: (vim.CustomFieldsManager.Value) []
the full traceback was:

Traceback (most recent call last):
File "/usr/local/bin/ansible-inventory", line 118, in <module>
exit_code = cli.run()
File "/usr/local/lib/python2.7/site-packages/ansible/cli/inventory.py", line 181, in run
results = self.dump(results)
File "/usr/local/lib/python2.7/site-packages/ansible/cli/inventory.py", line 195, in dump
results = yaml.dump(stuff, Dumper=AnsibleDumper, default_flow_style=False)
File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 202, in dump
return dump_all([data], stream, Dumper=Dumper, **kwds)
File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 190, in dump_all
dumper.represent(data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 28, in represent
node = self.represent_data(data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 225, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 67, in represent_data
node = self.yaml_representers[None](self, data)
File "/usr/local/lib/python2.7/site-packages/yaml/representer.py", line 249, in represent_undefined
raise RepresenterError("cannot represent an object: %s" % data)
RepresenterError: cannot represent an object: (vim.CustomFieldsManager.Value) []

# Fixed code
def _populate_from_cache(self, source_data):
    """Populate cache using source data"""
    hostvars = source_data.pop("_meta", {}).get("hostvars", {})
    for group in source_data:
        if group == "all":
            continue
        else:
            self.inventory.add_group(group)
            hosts = source_data[group].get("hosts", [])
            for host in hosts:
                self._populate_host_vars([host], hostvars.get(host, {}), group)
            self.inventory.add_child("all", group)