TypeError: Plural value must be an integer, got str
Closed this issue · 2 comments
sentry-io commented
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"}}
Bjwebb commented
(this issue was added by me)
Bjwebb commented
This should be fixed by 8ea3d65#diff-5519fbfdf13a0c1bb988855c09b2fef735231c6045e59ad21ca9e593001d173dR33