Обсуждение: [PATCH] pgarchives: bugfix: increase listsubscription username length
The listsubscription username field is populated by pglister_sync,
copying information from auth_user.email, which can be up to
254 characters.
If a user defined an email address that is longer than 30
characters, pglister_sync will crash:
Traceback (most recent call last):
File "/path/pglister_sync.py", line 83, in <module>
curs.execute("WITH t(u) AS (SELECT UNNEST(%(usernames)s::text[])), ins(un) AS (INSERT INTO listsubscribers
(username,list_id) SELECT u, %(listid)s FROM t WHERE NOT EXISTS (SELECT 1 FROM listsubscribers WHERE username=u AND
list_id=%(listid)s)RETURNING username), del(un) AS (DELETE FROM listsubscribers WHERE list_id=%(listid)s AND NOT EXISTS
(SELECT1 FROM t WHERE u=username) RETURNING username) SELECT 'ins',un FROM ins UNION ALL SELECT 'del',un FROM del ORDER
BY1,2", {
psycopg2.errors.StringDataRightTruncation: value too long for type character varying(30)
This patch fixes the issue by using the same max length as any
django email field for this field.
--
Célestin Matte
Вложения
Correction: the field is copied from auth_user.username, which is max 150 characters: https://docs.djangoproject.com/en/5.2/ref/contrib/auth/#django.contrib.auth.models.User.username Corrected patch attached On 22/09/2025 21:13, Célestin Matte wrote: > The listsubscription username field is populated by pglister_sync, > copying information from auth_user.email, which can be up to > 254 characters. > If a user defined an email address that is longer than 30 > characters, pglister_sync will crash: > > Traceback (most recent call last): > File "/path/pglister_sync.py", line 83, in <module> > curs.execute("WITH t(u) AS (SELECT UNNEST(%(usernames)s::text[])), ins(un) AS (INSERT INTO listsubscribers (username,list_id) SELECT u, %(listid)s FROM t WHERE NOT EXISTS (SELECT 1 FROM listsubscribers WHERE username=u AND list_id=%(listid)s)RETURNING username), del(un) AS (DELETE FROM listsubscribers WHERE list_id=%(listid)s AND NOT EXISTS (SELECT1 FROM t WHERE u=username) RETURNING username) SELECT 'ins',un FROM ins UNION ALL SELECT 'del',un FROM del ORDER BY1,2", { > psycopg2.errors.StringDataRightTruncation: value too long for type character varying(30) > > This patch fixes the issue by using the same max length as any > django email field for this field. -- Célestin Matte
Вложения
Hi!
Better late than never, this has been pushed. Sorry about the delay!
//Magnus
On Mon, 22 Sept 2025 at 21:28, Célestin Matte <celestin.matte@cmatte.me> wrote:
Correction: the field is copied from auth_user.username, which is max 150 characters: https://docs.djangoproject.com/en/5.2/ref/contrib/auth/#django.contrib.auth.models.User.username
Corrected patch attached
On 22/09/2025 21:13, Célestin Matte wrote:
> The listsubscription username field is populated by pglister_sync,
> copying information from auth_user.email, which can be up to
> 254 characters.
> If a user defined an email address that is longer than 30
> characters, pglister_sync will crash:
>
> Traceback (most recent call last):
> File "/path/pglister_sync.py", line 83, in <module>
> curs.execute("WITH t(u) AS (SELECT UNNEST(%(usernames)s::text[])), ins(un) AS (INSERT INTO listsubscribers (username, list_id) SELECT u, %(listid)s FROM t WHERE NOT EXISTS (SELECT 1 FROM listsubscribers WHERE username=u AND list_id=%(listid)s) RETURNING username), del(un) AS (DELETE FROM listsubscribers WHERE list_id=%(listid)s AND NOT EXISTS (SELECT 1 FROM t WHERE u=username) RETURNING username) SELECT 'ins',un FROM ins UNION ALL SELECT 'del',un FROM del ORDER BY 1,2", {
> psycopg2.errors.StringDataRightTruncation: value too long for type character varying(30)
>
> This patch fixes the issue by using the same max length as any
> django email field for this field.
--
Célestin Matte