Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudEvent equality is incorrect on none attributes #199

Open
sasha-tkachev opened this issue Nov 9, 2022 · 4 comments
Open

CloudEvent equality is incorrect on none attributes #199

sasha-tkachev opened this issue Nov 9, 2022 · 4 comments

Comments

@sasha-tkachev
Copy link
Contributor

CloudEvent equality is incorrect on none attributes

from cloudevents.http import CloudEvent
CloudEvent(attributes={"type": "a", "source": "a", "a": None}) == CloudEvent({"type": "a", "source":"a"})

expected True

actual False

the spec says that null value attributes are the same as non-existing attributes

@xSAVIKx
Copy link
Member

xSAVIKx commented Nov 9, 2022

Can you please point to a specific place where this is stated in the spec? I have a pretty hard time finding this in the spec.

@sasha-tkachev
Copy link
Contributor Author

It is specified only in the JSON format type system mapping I even think we MUST NOT allow None values for attributes. Because it is not a supported attribute type

@xSAVIKx
Copy link
Member

xSAVIKx commented Nov 11, 2022

Unset attributes MAY be encoded to the JSON value of null

So looks like None is a valid input.

Also, we're talking about JSON representation of the event, not about language-specific representation. IMO, it means that to_json(CloudEvent(attributes={"type": "a", "source": "a", "a": None})) must be == to to_json(CloudEvent({"type": "a", "source":"a"})). But it does not require CloudEvent instances to be equal.

@xSAVIKx
Copy link
Member

xSAVIKx commented Nov 11, 2022

Or actually:

from_json(to_json(CloudEvent(attributes={"type": "a", "source": "a", "a": None}))) must be == to from_json(to_json(CloudEvent({"type": "a", "source":"a"})))

So we must be treating JSON representation with null or without a value in the very same way. But it is not required for the instance of CloudEvent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants