Skip to content

Commit

Permalink
when we get the value deserialized from json it can be objectid (#2443)
Browse files Browse the repository at this point in the history
and then it fails when calling .find() on it.
that happens on conditions working with ids eg on desks.

SDESK-6883
  • Loading branch information
petrjasek authored Apr 17, 2023
1 parent 3ad0cea commit 2c1eb40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions apps/content_filters/content_filter/content_filter_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def does_match(self, content_filter, article, filters=None):
if filters
else filter_condition_service.get_cached_by_id(f)
)
if not fc:
logger.error("Missing filter condition %s in content filter %s", f, content_filter.get("name"))
return False
filter_condition = FilterCondition.parse(fc)
filter_conditions.append(filter_condition.does_match(article))
if "pf" in expression.get("expression", {}):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _get_regex_value(self):

def _get_value(self, field):
t = field.get_type()
if self.value.find(",") > 0:
return [t(x) for x in self.value.strip().split(",")]
return [t(self.value)]
value = str(self.value)
if value.find(",") > 0:
return [t(x) for x in value.strip().split(",")]
return [t(value)]
4 changes: 2 additions & 2 deletions apps/publish/enqueue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def enqueue_items(self, published_items):
for queue_item in published_items:
try:
self.enqueue_item(queue_item)
except Exception:
logger.exception("Failed to queue item {}".format(queue_item.get("_id")))
except Exception as err:
logger.exception(err)
failed_items[str(queue_item.get("_id"))] = queue_item

if len(failed_items) > 0:
Expand Down

0 comments on commit 2c1eb40

Please sign in to comment.