Skip to content

ValueError when fetching next actions without any active agents

Sentry Issue: ARKINDEX-BACKEND-60

ValueError: min() arg is an empty sequence
(14 additional frame(s) were not displayed)
...
  File "rest_framework/fields.py", line 454, in get_attribute
    return get_attribute(instance, self.source_attrs)
  File "rest_framework/fields.py", line 99, in get_attribute
    instance = instance()
  File "contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "ponos/models.py", line 207, in next_actions
  File "ponos/models.py", line 179, in next_tasks

This might be a stale read issue that occurs when Arkindex has zero active agents, then an agent asks for its actions. Its last_ping gets updated, but the active agents are requested again by the actions serializer; the last ping update may not be replicated yet, so the active agents list can be empty.