# Buggy code
def login(self):
    service_type = self.params["service_type"]
    password = self.params["password"]

    login_org = None
    if service_type == "vcd":
        login_org = self.params["org"]

    if not self.vca.login(password=password, org=login_org):
        self.fail("Login to VCA failed", response=self.vca.response)

    try:
        method_name = "login_%s" % service_type
        meth = getattr(self, method_name)
        meth()
    except AttributeError:
        self.fail("no login method exists for service_type %s" % service_type)
    except VcaError as e:
        self.fail(e.message, response=self.vca.response, **e.kwargs)


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py", line 290, in <module>
main()
File "/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py", line 254, in main
supports_check_mode=True)
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 66, in __init__
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 140, in login
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 190, in fail
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 1993, in fail_json
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 1973, in _return_formatted
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 414, in remove_values
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 414, in <genexpr>
File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 425, in remove_values
TypeError: Value of unknown type: <class 'requests.models.Response'>, <Response [500]>

fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py\", line 290, in <module>\n    main()\n  File \"/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py\", line 254, in main\n    supports_check_mode=True)\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 66, in __init__\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 140, in login\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 190, in fail\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1993, in fail_json\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1973, in _return_formatted\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 414, in remove_values\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 414, in <genexpr>\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 425, in remove_values\nTypeError: Value of unknown type: <class 'requests.models.Response'>, <Response [500]>\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

# Fixed code
def login(self):
    service_type = self.params["service_type"]
    password = self.params["password"]

    login_org = None
    if service_type == "vcd":
        login_org = self.params["org"]

    if not self.vca.login(password=password, org=login_org):
        self.fail("Login to VCA failed", response=self.vca.response.content)

    try:
        method_name = "login_%s" % service_type
        meth = getattr(self, method_name)
        meth()
    except AttributeError:
        self.fail("no login method exists for service_type %s" % service_type)
    except VcaError as e:
        self.fail(e.message, response=self.vca.response.content, **e.kwargs)