public inbox for [email protected]
help / color / mirror / Atom feed[PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header
2+ messages / 2 participants
[nested] [flat]
* [PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header
@ 2026-06-12 08:52 Célestin Matte <[email protected]>
2026-06-12 10:25 ` Re: [PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header Magnus Hagander <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Célestin Matte @ 2026-06-12 08:52 UTC (permalink / raw)
To: PostgreSQL WWW <[email protected]>
Django crashes when receiving a request containing a If-Modified-Since header with an incorrect date:
Traceback (most recent call last):
File "/path/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/path/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/archives/mailarchives/views.py", line 112, in __cache
resp = fn(request, *_args, **_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/archives/mailarchives/views.py", line 500, in message
if ims >= newest:
^^^^^^^^^^^^^
Exception Type: TypeError at /message-id/<redacted>
Exception Value: '>=' not supported between instances of 'NoneType' and 'int'
This patch adds a condition to avoid this.
(For some reason, archives on postgresql.org do NOT crash on this. Are headers filtered before reaching pgarchives there? When deploying upstream version of pgarchives locally, I do have this crash)
--
Célestin Matte
Attachments:
[text/x-patch] 0001-Fix-crash-when-receiving-a-request-with-an-incorrect.patch (1.0K, ../../[email protected]/2-0001-Fix-crash-when-receiving-a-request-with-an-incorrect.patch)
download | inline diff:
From 0f1b7fd1b9c609811c05b8ee1c739b80d31ac491 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Thu, 11 Jun 2026 18:47:00 +0200
Subject: [PATCH] Fix crash when receiving a request with an incorrect
If-Modified-Since header
---
django/archives/mailarchives/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py
index fe74f7c..f258d5d 100644
--- a/django/archives/mailarchives/views.py
+++ b/django/archives/mailarchives/views.py
@@ -482,7 +482,7 @@ def message(request, msgid):
newest = calendar.timegm(max(threadstruct, key=lambda x: x['date'])['date'].utctimetuple())
if 'HTTP_IF_MODIFIED_SINCE' in request.META and not settings.DEBUG:
ims = parse_http_date_safe(request.META.get("HTTP_IF_MODIFIED_SINCE"))
- if ims >= newest:
+ if ims is not None and ims >= newest:
return HttpResponseNotModified()
responses = [t for t in threadstruct if t['parentid'] == m.id]
--
2.54.0
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header
2026-06-12 08:52 [PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header Célestin Matte <[email protected]>
@ 2026-06-12 10:25 ` Magnus Hagander <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Magnus Hagander @ 2026-06-12 10:25 UTC (permalink / raw)
To: Célestin Matte <[email protected]>; +Cc: PostgreSQL WWW <[email protected]>
On Fri, 12 Jun 2026 at 10:52, Célestin Matte <[email protected]>
wrote:
> Django crashes when receiving a request containing a If-Modified-Since
> header with an incorrect date:
>
>
> Traceback (most recent call last):
> File
> "/path/lib/python3.13/site-packages/django/core/handlers/exception.py",
> line 55, in inner
> response = get_response(request)
> ^^^^^^^^^^^^^^^^^^^^^
> File
> "/path/lib/python3.13/site-packages/django/core/handlers/base.py", line
> 197, in _get_response
> response = wrapped_callback(request, *callback_args,
> **callback_kwargs)
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/path/archives/mailarchives/views.py", line 112, in __cache
> resp = fn(request, *_args, **_kwargs)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/path/archives/mailarchives/views.py", line 500, in message
> if ims >= newest:
> ^^^^^^^^^^^^^
>
> Exception Type: TypeError at /message-id/<redacted>
> Exception Value: '>=' not supported between instances of 'NoneType' and
> 'int'
>
>
> This patch adds a condition to avoid this.
>
Good catch. Applied. Thanks!
>
> (For some reason, archives on postgresql.org do NOT crash on this. Are
> headers filtered before reaching pgarchives there? When deploying upstream
> version of pgarchives locally, I do have this crash)
>
IMS in particular is handled by the cache. So the brwoser does IMS <-> the
cache, and then varnish does it independently <-> backend. And Varnish will
always create the correct headers. And since headers from the client are
never passed through to the backend, it doesn't show up there.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-06-12 10:25 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12 08:52 [PATCH] pgarchives: Fix crash when receiving a request with an incorrect If-Modified-Since header Célestin Matte <[email protected]>
2026-06-12 10:25 ` Magnus Hagander <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox