Skip to content
Open
Changes from all commits
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
29 changes: 24 additions & 5 deletions backend/kernelCI_app/helpers/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,33 @@ def sanitize_tree(
"skip": checkout["skip_boots"],
}

if isinstance(checkout.get("git_commit_tags"), str):
# Has to check if it's a string because sqlite doesn't support ArrayFields.
# So if the query came from sqlite, it will be a string.
git_commit_tags = checkout.get("git_commit_tags")
if isinstance(git_commit_tags, str):
try:
checkout["git_commit_tags"] = json.loads(checkout["git_commit_tags"])
if not isinstance(checkout["git_commit_tags"], list):
checkout["git_commit_tags"] = []
except json.JSONDecodeError:
checkout["git_commit_tags"] = json.loads(git_commit_tags)
except (TypeError, json.JSONDecodeError):
log_message(
"git_commit_tags could not be decoded for checkout_id %s"
% checkout["checkout_id"],
)
checkout["git_commit_tags"] = []

if not isinstance(checkout["git_commit_tags"], list):
log_message(
"git_commit_tags is not a list for checkout_id %s"
% checkout["checkout_id"],
)
checkout["git_commit_tags"] = []

# The git_commit_tags comes as list[str] on a normal query, but `Checkout` expects list[list[str]].
# This is a workaround, the queries should *always* return a simple list[str]
if checkout["git_commit_tags"] and not isinstance(
checkout["git_commit_tags"][0], list
):
checkout["git_commit_tags"] = [checkout["git_commit_tags"]]

return Checkout(
**checkout,
build_status=build_status,
Expand Down