open-contracting/cove-ocds

TypeError: Plural value must be an integer, got str

Closed this issue · 2 comments

Sentry Issue: COVE-OCDS-3J

TypeError: Plural value must be an integer, got str
(43 additional frame(s) were not displayed)
...
  File "django/utils/translation/trans_real.py", line 395, in do_ntranslate
    return getattr(t, translation_function)(singular, plural, number)
  File "django/utils/translation/trans_real.py", line 250, in ngettext
    tmsg = self._catalog.plural(msgid1, n)
  File "django/utils/translation/trans_real.py", line 111, in plural
    tmsg = cat.get((msgid, plural(num)))
  File "<string>", line 4, in func
  File "gettext.py", line 166, in _as_int
    (n.__class__.__name__,)) from None

The plural that is a problem is https://github.com/open-contracting/cove-ocds/blob/master/cove_ocds/templates/cove_ocds/explore_record.html#L33

This happens when records_aggregates is empty, because the data is bad (in this case records was an object, not an array).

Minimal example to reproduce:

{"records":{"ocid": "test"}}

(this issue was added by me)