# Buggy code
def _prepare_result(self):
    return {
        "id": to_native(self.hcloud_server.id),
        "name": to_native(self.hcloud_server.name),
        "ipv4_address": to_native(self.hcloud_server.public_net.ipv4.ip),
        "ipv6": to_native(self.hcloud_server.public_net.ipv6.ip),
        "image": to_native(self.hcloud_server.image.name),
        "server_type": to_native(self.hcloud_server.server_type.name),
        "datacenter": to_native(self.hcloud_server.datacenter.name),
        "location": to_native(self.hcloud_server.datacenter.location.name),
        "rescue_enabled": self.hcloud_server.rescue_enabled,
        "backup_window": to_native(self.hcloud_server.backup_window),
        "labels": self.hcloud_server.labels,
        "delete_protection": self.hcloud_server.protection["delete"],
        "rebuild_protection": self.hcloud_server.protection["rebuild"],
        "status": to_native(self.hcloud_server.status),
    }


# Traceback (AttributeError)
The full traceback is:
Traceback (most recent call last):
File "/home/andor/.ansible/tmp/ansible-tmp-1573035298.4213414-249660851701701/AnsiballZ_hcloud_server_info.py", line 102,
in <module>
_ansiballz_main()
File "/home/andor/.ansible/tmp/ansible-tmp-1573035298.4213414-249660851701701/AnsiballZ_hcloud_server_info.py", line 94,
in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/andor/.ansible/tmp/ansible-tmp-1573035298.4213414-249660851701701/AnsiballZ_hcloud_server_info.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible.modules.cloud.hcloud.hcloud_server_info', init_globals=None, run_name='__main__', alter_sys=False)
File "/usr/lib/python3.7/runpy.py", line 208, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_hcloud_server_info_payload_x1rpfqer/ansible_hcloud_server_info_payload.zip/ansible/modules/cloud/hcloud/hcloud_server_info.py", line 214, in <module>
File "/tmp/ansible_hcloud_server_info_payload_x1rpfqer/ansible_hcloud_server_info_payload.zip/ansible/modules/cloud/hcloud/hcloud_server_info.py", line 199, in main
File "/tmp/ansible_hcloud_server_info_payload_x1rpfqer/ansible_hcloud_server_info_payload.zip/ansible/module_utils/hcloud.py", line 62, in get_result
File "/tmp/ansible_hcloud_server_info_payload_x1rpfqer/ansible_hcloud_server_info_payload.zip/ansible/modules/cloud/hcloud/hcloud_server_info.py", line 146, in _prepare_result
AttributeError: 'NoneType' object has no attribute 'name'

# Fixed code
def _prepare_result(self):
    image = (
        None
        if self.hcloud_server.image is None
        else to_native(self.hcloud_server.image.name)
    )
    return {
        "id": to_native(self.hcloud_server.id),
        "name": to_native(self.hcloud_server.name),
        "ipv4_address": to_native(self.hcloud_server.public_net.ipv4.ip),
        "ipv6": to_native(self.hcloud_server.public_net.ipv6.ip),
        "image": image,
        "server_type": to_native(self.hcloud_server.server_type.name),
        "datacenter": to_native(self.hcloud_server.datacenter.name),
        "location": to_native(self.hcloud_server.datacenter.location.name),
        "rescue_enabled": self.hcloud_server.rescue_enabled,
        "backup_window": to_native(self.hcloud_server.backup_window),
        "labels": self.hcloud_server.labels,
        "delete_protection": self.hcloud_server.protection["delete"],
        "rebuild_protection": self.hcloud_server.protection["rebuild"],
        "status": to_native(self.hcloud_server.status),
    }