Sanjays2402 opened a new pull request, #2159:
URL: https://github.com/apache/libcloud/pull/2159

   ## Summary
   
   Fixes #1893.
   
   For the Azure ARM driver, `create_node` failed when `ex_customdata` was 
provided:
   
   - `base64.b64encode()` returns `bytes`, which is not JSON serializable, so 
building the request body raised `Object of type bytes is not JSON 
serializable`.
   - Passing `ex_customdata` as a `str` failed earlier because `b64encode` 
requires bytes-like input.
   
   ## Fix
   
   Normalize `ex_customdata` to `bytes` before encoding, then 
`.decode("utf-8")` the base64 output so `customData` is a JSON-serializable 
`str`. Both `str` and `bytes` inputs are now accepted.
   
   ## Testing
   
   Added `test_create_node_ex_customdata` which exercises both `str` and 
`bytes` inputs, asserts `customData` is the expected base64 `str`, and asserts 
the resulting properties dict is JSON-serializable via `json.dumps`.
   
   - Without the fix: the new test fails with `TypeError` in `base64`.
   - With the fix: the new test passes and the full `test_azure_arm.py` suite 
(46 tests) passes.
   - `black --check` and `flake8` are clean on the changed files.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to