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

Data contains dictionary if value is empty #166

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ayon_api/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8134,11 +8134,14 @@ def send_batch_operations(
return op_results

def _convert_entity_data(self, entity):
if not entity:
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 = {}
Copy link

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 {}

Copy link
Member Author

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.

Copy link

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.


elif isinstance(entity_data, str):
entity_data = json.loads(entity_data)

entity["data"] = entity_data