API modifies power_address with special chars

Bug #1887700 reported by GILLES
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
MAAS
Invalid
Undecided
Unassigned

Bug Description

MAAS version: 2.7.0 (8232-g.6e1dba4ab-0ubuntu1~18.04.1)

When using Rest API to provide power_parameters special chars (+) seems to be replaced by white space.
The problem occurs when for a power_address using "qemu+ssh://"

Example :

PUT /MAAS/api/2.0/machines/XXXX/ HTTP/1.1
Accept-Encoding: identity
Content-Length: 137
Connection: close
Accept: application/json
User-Agent: ansible-httpget
Host: XXXXX:5240
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_consumer_key="XXXXX", oauth_token="XXXXXX", oauth_signature_method="PLAINTEXT", oauth_timestamp="XXXXXXX", oauth_nonce="XXXXX", oauth_version="1.0", oauth_signature="XXXXXXXXX"

hostname=XXXX;power_type=virsh;power_parameters={"power_address":"qemu+ssh://root@XXXXX/system", "power_id":"XXXXX"}

When using the GUI to see the result, power_address has been rewritten as "qemu ssh://root@XXXXX/system"
And of course the commisioning is not working.
The result should be "qemu+ssh://root@XXXXX/system"

Whereas configuring this power_address through GUI is working fine.

Revision history for this message
GILLES (antgilles) wrote :

Workaround found by using unicode %2B instead of "+" in the power_address value.

Payload need to be : power_type=virsh;power_parameters={"power_address":"qemu%2Bssh://root@XXXXX/system", "power_id":"XXXXX"}

Revision history for this message
Alberto Donato (ack) wrote :

This is not a workaround, but the expected behavior. When making requests to the API, parameters need to be correctly encoded.

The x-www-form-encoding content-type requires + to be encoded as "%2B" (as + is used to encode spaces).

Changed in maas:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.