MozillaFoundation / foundation.mozilla.org

Mozilla Foundation website
https://foundation.mozilla.org
Mozilla Public License 2.0
389 stars 153 forks source link

Crash on https://foundation.mozilla.org/sw/common-voice/blog/ #10343

Closed TheoChevalier closed 3 months ago

TheoChevalier commented 1 year ago

Opening the Kiswahili page of the blog section from the Common Voice microsite https://foundation.mozilla.org/sw/common-voice/blog/ crashes with networkapi.wagtailpages.pagemodels.blog.blog_index.BlogIndexPage.DoesNotExist: BlogIndexPage matching query does not exist.

Note: only the Kiswahili version crashes, all other locales work fine. I don’t see anything wrong in the translations, so I’m not sure what could be the cause. Maybe something from a translated blog post loaded in the page?

Another theory, Kiswahili is the only locale where the translation of "Blog" is a different word (it’s "Blogu"), could it be the code is looking up for the blog index using the translated title, thus not finding it?

Full crash log:

2023-03-16T14:43:25.972353+00:00 heroku[router]: at=info method=GET path="/sw/common-voice/blog/" host=foundation.mozilla.org request_id=e4a3e825-8f16-4b02-9138-b127ec8d0c5e fwd="86.201.15.200,172.71.130.161" dyno=web.5 connect=0ms service=329ms status=500 bytes=3053 protocol=https

2023-03-16T14:43:25.965070+00:00 app[web.5]: Internal Server Error: /sw/common-voice/blog/

2023-03-16T14:43:25.965086+00:00 app[web.5]: Traceback (most recent call last):

2023-03-16T14:43:25.965087+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner

2023-03-16T14:43:25.965088+00:00 app[web.5]:     response = get_response(request)

2023-03-16T14:43:25.965089+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 204, in _get_response

2023-03-16T14:43:25.965089+00:00 app[web.5]:     response = response.render()

2023-03-16T14:43:25.965090+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/response.py", line 105, in render

2023-03-16T14:43:25.965090+00:00 app[web.5]:     self.content = self.rendered_content

2023-03-16T14:43:25.965092+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/sentry_sdk/integrations/django/templates.py", line 73, in rendered_content

2023-03-16T14:43:25.965092+00:00 app[web.5]:     return real_rendered_content.fget(self)

2023-03-16T14:43:25.965092+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/response.py", line 83, in rendered_content

2023-03-16T14:43:25.965093+00:00 app[web.5]:     return template.render(context, self._request)

2023-03-16T14:43:25.965094+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render

2023-03-16T14:43:25.965094+00:00 app[web.5]:     return self.template.render(context)

2023-03-16T14:43:25.965094+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965095+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965098+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 170, in render

2023-03-16T14:43:25.965099+00:00 app[web.5]:     return self._render(context)

2023-03-16T14:43:25.965099+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render

2023-03-16T14:43:25.965100+00:00 app[web.5]:     return self.nodelist.render(context)

2023-03-16T14:43:25.965100+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965101+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965101+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965103+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965103+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render

2023-03-16T14:43:25.965103+00:00 app[web.5]:     return compiled_parent._render(context)

2023-03-16T14:43:25.965104+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render

2023-03-16T14:43:25.965104+00:00 app[web.5]:     return self.nodelist.render(context)

2023-03-16T14:43:25.965104+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965105+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965105+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965105+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965106+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render

2023-03-16T14:43:25.965106+00:00 app[web.5]:     return compiled_parent._render(context)

2023-03-16T14:43:25.965107+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render

2023-03-16T14:43:25.965108+00:00 app[web.5]:     return self.nodelist.render(context)

2023-03-16T14:43:25.965108+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965108+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965108+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965109+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965109+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render

2023-03-16T14:43:25.965110+00:00 app[web.5]:     return compiled_parent._render(context)

2023-03-16T14:43:25.965110+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render

2023-03-16T14:43:25.965110+00:00 app[web.5]:     return self.nodelist.render(context)

2023-03-16T14:43:25.965111+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965111+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965111+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965112+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965112+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render

2023-03-16T14:43:25.965112+00:00 app[web.5]:     return compiled_parent._render(context)

2023-03-16T14:43:25.965113+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render

2023-03-16T14:43:25.965113+00:00 app[web.5]:     return self.nodelist.render(context)

2023-03-16T14:43:25.965113+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965114+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965114+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965114+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965120+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965120+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965120+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render

2023-03-16T14:43:25.965121+00:00 app[web.5]:     result = block.nodelist.render(context)

2023-03-16T14:43:25.965121+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965121+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965122+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965122+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965122+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965122+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965123+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render

2023-03-16T14:43:25.965123+00:00 app[web.5]:     result = block.nodelist.render(context)

2023-03-16T14:43:25.965140+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965141+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965141+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965144+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965144+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965144+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965145+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render

2023-03-16T14:43:25.965145+00:00 app[web.5]:     result = block.nodelist.render(context)

2023-03-16T14:43:25.965145+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965146+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965146+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965146+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965146+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965147+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965147+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render

2023-03-16T14:43:25.965147+00:00 app[web.5]:     result = block.nodelist.render(context)

2023-03-16T14:43:25.965147+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965148+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965148+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965148+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965148+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/scout_apm/core/stacktracer.py", line 25, in wrapper

2023-03-16T14:43:25.965149+00:00 app[web.5]:     return wrapped(*args, **kwargs)

2023-03-16T14:43:25.965149+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render

2023-03-16T14:43:25.965149+00:00 app[web.5]:     result = block.nodelist.render(context)

2023-03-16T14:43:25.965149+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render

2023-03-16T14:43:25.965150+00:00 app[web.5]:     bit = node.render_annotated(context)

2023-03-16T14:43:25.965150+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965150+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965150+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/defaulttags.py", line 214, in render

2023-03-16T14:43:25.965151+00:00 app[web.5]:     nodelist.append(node.render_annotated(context))

2023-03-16T14:43:25.965151+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated

2023-03-16T14:43:25.965151+00:00 app[web.5]:     return self.render(context)

2023-03-16T14:43:25.965152+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/wagtail/templatetags/wagtailcore_tags.py", line 137, in render

2023-03-16T14:43:25.965152+00:00 app[web.5]:     output = value.render_as_block(context=new_context)

2023-03-16T14:43:25.965152+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/wagtail/blocks/base.py", line 439, in render_as_block

2023-03-16T14:43:25.965153+00:00 app[web.5]:     return self.block.render(self.value, context=context)

2023-03-16T14:43:25.965153+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/wagtail/blocks/base.py", line 229, in render

2023-03-16T14:43:25.965154+00:00 app[web.5]:     new_context = self.get_context(value, parent_context=dict(context))

2023-03-16T14:43:25.965155+00:00 app[web.5]:   File "/app/network-api/networkapi/wagtailpages/pagemodels/customblocks/recent_blog_entries.py", line 47, in get_context

2023-03-16T14:43:25.965155+00:00 app[web.5]:     blog_page = BlogIndexPage.objects.get(title__iexact="blog", locale=locale)

2023-03-16T14:43:25.965156+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method

2023-03-16T14:43:25.965160+00:00 app[web.5]:     return getattr(self.get_queryset(), name)(*args, **kwargs)

2023-03-16T14:43:25.965160+00:00 app[web.5]:   File "/app/.heroku/python/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get

2023-03-16T14:43:25.965161+00:00 app[web.5]:     raise self.model.DoesNotExist(

2023-03-16T14:43:25.965161+00:00 app[web.5]: networkapi.wagtailpages.pagemodels.blog.blog_index.BlogIndexPage.DoesNotExist: BlogIndexPage matching query does not exist.

┆Issue is synchronized with this Jira Bug

TheoChevalier commented 1 year ago

Another theory, Kiswahili is the only locale where the translation of "Blog" is a different word (it’s "Blogu"), could it be the code is looking up for the blog index using the translated title, thus not finding it?

This seem to be the right theory, updating the title translation on https://foundation.mozilla.org/sw/blog/ fixes the issue.

I think this needs to be updated: https://github.com/MozillaFoundation/foundation.mozilla.org/blob/main/network-api/networkapi/wagtailpages/pagemodels/blog/blog.py#L277-L279

kevinhowbrook commented 1 year ago

We could probably do this using Q

from django.db.models import Q

blog_page = BlogIndexPage.objects.get(Q(title__iexact="Blog") | Q(title__iexact="Blogu"), locale=default_locale)

It doesn't fix the underlining issue and if another index is created with "Bloga" it would throw the same exception. We should also wrap it in a try / except to avoid crashing the page

robdivincenzo commented 4 months ago

@TheoChevalier fyi- a fix for this is on staging, and will be live next deployment

data-sync-user commented 3 months ago

➤ Simon Acosta Torres commented:

Rob DiVincenzo Whenever you have some time, could we revisit this ticket and see if we should still tackle and how easy this would be considering Kevin latest comment?