diff options
author | Scott Moser <smoser@brickies.net> | 2017-02-16 21:13:38 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-02-16 22:04:37 -0500 |
commit | 91be1d189d9348e81a4c4f1f7d5fc255df1ce6d1 (patch) | |
tree | fa98277ed77068ce9eb09476e1c944313d603e75 | |
parent | 1cd8cfaf1b4d0e3a97c693469d6d987d55014280 (diff) | |
download | vyos-cloud-init-91be1d189d9348e81a4c4f1f7d5fc255df1ce6d1.tar.gz vyos-cloud-init-91be1d189d9348e81a4c4f1f7d5fc255df1ce6d1.zip |
ec2_utils: fix MetadataLeafDecoder that returned bytes on empty
the MetadataLeafDecoder would return a bytes value b'' instead of
an empty string if the value of a key was empty. In all other cases
the value would be a string.
This was discovered when trying to json.dumps(get_instance_metadata())
on a recent OpenStack, where the value of 'public-ipv4' was empty.
The attempt to dump that with json would raise
TypeError: b'' is not JSON serializable
-rw-r--r-- | cloudinit/ec2_utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cloudinit/ec2_utils.py b/cloudinit/ec2_utils.py index 0c16ae47..13691549 100644 --- a/cloudinit/ec2_utils.py +++ b/cloudinit/ec2_utils.py @@ -28,7 +28,7 @@ class MetadataLeafDecoder(object): def __call__(self, field, blob): if not blob: - return blob + return '' try: blob = util.decode_binary(blob) except UnicodeDecodeError: |