Skip to content

NotificationReceiver fails on message body with empty string #2256

Description

@andy-maier

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions