Skip to content

Fix Azure ARM create_node JSON error with ex_customdata (#1893)#2159

Merged
micafer merged 3 commits into
apache:trunkfrom
Sanjays2402:fix/azure-arm-customdata-1893
Jul 20, 2026
Merged

Fix Azure ARM create_node JSON error with ex_customdata (#1893)#2159
micafer merged 3 commits into
apache:trunkfrom
Sanjays2402:fix/azure-arm-customdata-1893

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Description

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 also failed because b64encode requires bytes-like input.

The fix normalizes ex_customdata to bytes, then decodes the base64 result to a UTF-8 str so customData is JSON-serializable. Both str and bytes inputs are now accepted.

Status

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks) — black --check and flake8 clean on changed files
  • Documentation
  • Tests — added test_create_node_ex_customdata (str + bytes); fails without the fix, passes with it; full test_azure_arm.py = 46 passed
  • ICLA (required for bigger changes) — small bugfix

base64.b64encode returns bytes, which is not JSON serializable and
raised 'Object of type bytes is not JSON serializable' when
ex_customdata was passed to create_node. It also failed outright when
ex_customdata was a str. The value is now normalized to bytes before
encoding and the base64 result is decoded to a str so the resulting
request body is valid JSON.

Closes: GITHUB-1893
@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.39%. Comparing base (fbbfd08) to head (d74c50e).

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2159      +/-   ##
==========================================
+ Coverage   83.38%   83.39%   +0.01%     
==========================================
  Files         351      351              
  Lines       81457    81476      +19     
  Branches     8745     8746       +1     
==========================================
+ Hits        67919    67940      +21     
+ Misses      10745    10744       -1     
+ Partials     2793     2792       -1     
Files with missing lines Coverage Δ
libcloud/compute/drivers/azure_arm.py 60.73% <100.00%> (+0.39%) ⬆️
libcloud/test/compute/test_azure_arm.py 99.01% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@micafer micafer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@micafer
micafer enabled auto-merge July 20, 2026 08:07
@micafer
micafer merged commit c8a13eb into apache:trunk Jul 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure arm ex_customdata causes json error

3 participants