-
Notifications
You must be signed in to change notification settings - Fork 4
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
Data contains dictionary if value is empty #166
Conversation
ayon_api/server_api.py
Outdated
if not entity or "data" not in entity: | ||
return | ||
entity_data = entity.get("data") | ||
if ( | ||
entity_data is not None | ||
and isinstance(entity_data, str) | ||
): | ||
entity["data"] = json.loads(entity_data) | ||
|
||
entity_data = entity["data"] | ||
if entity_data is None: | ||
entity_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.
Isn't this quite similar as to just doing entity_data = entity.get("data") or {}
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.
"data"
should not be filled if are not available in entity.
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.
I see - we may want to update the PR description then to explain that with this PR it entity will also lack "data"
completely whereas previously it may have been None
. The PR isn't necessarily enforcing data
to be dict
but only enforcing that it will be - if it was existing in in the input 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.
Didn't test but code looks good to me.
I did want to point out the comment made here that the PR may do more than the PR description describes currently.
Also, not sure how to really test this? As in, when is data empty on the server? :)
All new entities that don't have anything in |
Description
Use empty dictionary when
"data"
value isNone
.Additional information
When data are empty on entity server does return
None
instead of"{}"
, added functionality makesNone
value as dictionary.