On behalf of Michael Ward, IBM:
Description
NotificationReceiver.notifications() currently attempts to parse any non-None message body using json.loads(). However, some valid HMC notification types, such as job-completion, can have an empty message body (''). Because an empty string is not valid JSON, the following code path (in the implementation of notifications ) raises NotificationParseError:
if item.message is None:
msg_obj = None
else:
msg_obj = json.loads(item.message)
As a result, valid notifications cannot be consumed through the generator without explicitly catching and handling NotificationParseError .
Actual Behavior
Notifications with empty message bodies cause json.loads('') to fail, resulting in a NotificationParseError and interrupting notification processing.
Expected Behavior
Notifications with empty message bodies should be treated as valid and yielded successfully, for example by treating an empty string the same as a missing body and returning message=None.
On behalf of Michael Ward, IBM:
Description
NotificationReceiver.notifications() currently attempts to parse any non-None message body using json.loads(). However, some valid HMC notification types, such as job-completion, can have an empty message body (''). Because an empty string is not valid JSON, the following code path (in the implementation of notifications ) raises NotificationParseError:
As a result, valid notifications cannot be consumed through the generator without explicitly catching and handling NotificationParseError .
Actual Behavior
Notifications with empty message bodies cause json.loads('') to fail, resulting in a NotificationParseError and interrupting notification processing.
Expected Behavior
Notifications with empty message bodies should be treated as valid and yielded successfully, for example by treating an empty string the same as a missing body and returning message=None.