Skip to content

Commit

Permalink
OSIDB-3579: Handle models without manager (#860)
Browse files Browse the repository at this point in the history
From my testing locally, all content-types had a manager to acces the
`model.objects` field, but on stage, this task is failing because
there's at least one model without a manager.

```
model_class.objects.filter(
AttributeError: 'NoneType' object has no attribute 'objects'
```

I've added a  log message to report the error and continue the loop.
  • Loading branch information
MrMarble authored Dec 13, 2024
2 parents 141377b + 6ea860e commit d5598e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions osidb/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def stale_alert_cleanup():
for content_type in content_types:
model_class = content_type.model_class()

if not model_class:
logger.error(f"Model class not found for content type {content_type}")
continue

subquery = Subquery(
model_class.objects.filter(
pk=Cast(OuterRef("object_id"), output_field=model_class._meta.pk)
Expand Down

0 comments on commit d5598e6

Please sign in to comment.