pyvcloud icon indicating copy to clipboard operation
pyvcloud copied to clipboard

Unable to get VDC vAPPs by name due to characters within vAPP name

Open exp-hc opened this issue 5 years ago • 4 comments

Unable to use get_vapp in pyvcloud.vcd.vdc.VDC when vAPP names contain opening parenthesis without a closing parenthesis.

Example exception: pyvcloud.vcd.vdc.VDC.get_vapp('Discovered VM Name (')

Exception: %sStatus code: 400/BAD_REQUEST, Bad request: Unmatched opening and closing brackets in expression vdc==https://-vCD URI-/api/vdc/-vdc uuid-;name==Discovered VM Name (. (request id: -uuid-)

exp-hc avatar Jun 23 '20 16:06 exp-hc

IMHO, this is rather a bug in vCloud (server-side) than from the pyvcloud module. In pyvcloud the query filter is correctly encoded using urllib.parse.quote(). Have you already opened a ticket at VMware support?

dwettstein avatar Jul 17 '20 10:07 dwettstein

Having a similar problem: pyvcloud.vcd.vdc.get_vapp_href(vapp_name) Generates the same exception, when vapp_name contains opening parenthesis without a closing parenthesis.

A little workaround helped me: parsing vapp href from API response when getting a VDC resource.

kargerova avatar Dec 06 '20 20:12 kargerova

+1, hitting this problem through vcd-cli

tsener avatar Dec 07 '20 12:12 tsener

IMHO, this is rather a bug in vCloud (server-side) than from the pyvcloud module. In pyvcloud the query filter is correctly encoded using urllib.parse.quote(). Have you already opened a ticket at VMware support?

Upd. The cause of the error is the function "def _escape_special_characters(self, single_encoded_value_string):" in module "client.py". This causes escaping of parentheses, both opening and closing. After disabling parenthesis escaping the error does not appear.

Hidmink avatar Feb 07 '24 08:02 Hidmink