-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Improved error message in the from_dict
#19416
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
Changes from 1 commit
2b8283e
e3fc8e6
f09c3c8
18b3999
1cc83d9
3091e9c
53660ec
b43d1a3
10d2d0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,16 @@ def from_dict(cls, event): | |
| :type event: dict | ||
| :rtype: CloudEvent | ||
| """ | ||
| if not all([_ in event for _ in ("source", "type")]): | ||
| if all([_ in event for _ in (("subject", "eventType", "data", "dataVersion", "id", "eventTime"))]): | ||
| raise ValueError( | ||
| "The event does not conform to the cloud event spec." + | ||
| " Try using the EventGridEvent from azure-eventgrid library" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would be more explicit: |
||
| ) | ||
| raise ValueError( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would do this whole block into a try/except around the |
||
| "The event does not conform to the cloud event spec. source and type are required." | ||
| ) | ||
|
|
||
| kwargs = {} # type: Dict[Any, Any] | ||
| reserved_attr = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these keys case-sensitive?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes - making it non case sensitive would be breaking |
||
| "data", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the description of the doc or a link?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added https://github.com/cloudevents/spec