From 22eb7cf67da3d12b3e40e686ff4ad4a87220e75a Mon Sep 17 00:00:00 2001 From: Kevin Rocker Date: Sat, 12 Sep 2026 13:51:40 +0200 Subject: [PATCH 1/2] Handle an empty mailing-list-month by responding with an empty mbox file --- django/archives/mailarchives/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py index 903632c..c034f90 100644 --- a/django/archives/mailarchives/views.py +++ b/django/archives/mailarchives/views.py @@ -690,6 +690,14 @@ def _build_mbox(query, params, msgid=None, filename=None): curs.execute(query, params) firstmsg = curs.fetchone() + if firstmsg is None: + # Nothing in range returns an empty file, not an error. + curs.close() + r = HttpResponse(b'', content_type='application/mbox') + if filename: + r['Content-Disposition'] = 'attachment; filename="%s"' % filename + return r + if msgid and firstmsg[0] != msgid: # Always redirect to the first message in the thread when building # the mbox, to not generate potentially multiple copies in -- 2.54.0