[Django] #29131: Error message of ArrayField is unfriendly and has excessive trailing space

12 views
Skip to first unread message

Django

unread,
Feb 14, 2018, 6:44:10 AM2/14/18
to django-...@googlegroups.com
#29131: Error message of ArrayField is unfriendly and has excessive trailing space
--------------------------------------------+------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
--------------------------------------------+------------------------
There's an `'item_invalid'` error message
`"Item %(nth)s in the array did not validate: "`

that has problems:

* While this message is shown to end user, it contains a 0-based index,
which can be a challenge to explain, even in english...

* I believe "list" would be a better term instead of "array" for general
public. The same goes for my language.

* Additional message is concatenated right after this, so the trailing
space is needed in translations too. But on Transifex and many other i18n
tools the space is not apparent.

What about something like this:

`"Item %(nth)s (count from the left) in the list is not valid:"`

--
Ticket URL: <https://code.djangoproject.com/ticket/29131>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 14, 2018, 10:40:19 AM2/14/18
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------

Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

I think indexing from 1 instead of 0 is an improvement.

Changing array to list might be okay, but what about all the messages in
the `ArrayField` model field that use "array".

About the addition of "(count from the left)"... I think that would be
better added in translational only for languages (if any?) where counting
in lists happens from the right?

I see your point about the trailing space -- the translated messages I
checked don't have the trailing space. I guess the idea would be to modify
`contrib.postgres.utils.prefix_validation_error()` to add the space
instead.

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:1>

Django

unread,
Feb 14, 2018, 3:44:40 PM2/14/18
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Vlada Macek):

> Changing array to list might be okay, but what about all the messages in
the ArrayField model field that use "array".

Quickly peeking... I'd say this could be the only message observable by
the end user.

> About the addition of "(count from the left)"... I think that would be
better added in translational only for languages (if any?) where counting
in lists happens from the right?

I proposed such suboptimal wording rather to point out the non-technical
people might not be even prepared to count items from either side.

The resulting concatenated message for
`ArrayField(base_field=models.EmailField)` looks like this:

`<field name>: Item %(nth)s in the array did not validate: Enter valid
e-mail address`

Personally I'd expect the value itself to be mentioned:

`<field name>: One of the values in the list (%(value)s) did not validate:
Enter valid e-mail address`

> I guess the idea would be to modify
`contrib.postgres.utils.prefix_validation_error()` to add the space
instead.

Exactly what I found out.

Thank you.

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:2>

Django

unread,
Apr 22, 2018, 10:19:13 PM4/22/18
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b33f10d8cc5037f49d5f9c462c510f0fcf11bcf5" b33f10d]:
{{{
#!CommitTicketReference repository=""
revision="b33f10d8cc5037f49d5f9c462c510f0fcf11bcf5"
Refs #29131 -- Made ArrayField error messages index from 1 instead of 0.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:3>

Django

unread,
May 13, 2018, 5:58:00 PM5/13/18
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"31ce1f74334add625a4ed82b531d769828237882" 31ce1f74]:
{{{
#!CommitTicketReference repository=""
revision="31ce1f74334add625a4ed82b531d769828237882"
Refs #29131 -- Fixed space handling in ArrayField's item_invalid message.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:4>

Django

unread,
May 13, 2018, 5:59:23 PM5/13/18
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:5>

Django

unread,
Mar 16, 2020, 6:56:16 AM3/16/20
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Pavel Savchenko):

This feature came as a surprise to us when we upgraded from 2.0 to 2.1, as
we were relying on 0-index (i.e we were adding +1 manually to ).

I guess it's too late for release notes (though we could mention it in
3.1?), though we could also mention that it's 1-indexed in the related
documentation here:

https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField.base_field

What do you think, shall we create a separate ticket for documenting this?

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:6>

Django

unread,
Mar 16, 2020, 7:24:55 AM3/16/20
to django-...@googlegroups.com
#29131: Make the error message for ArrayField more user and translation-friendly
--------------------------------------+------------------------------------
Reporter: Vlada Macek | Owner: (none)
Type: Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by felixxm):

I'm not sure what kind of change or documentation improvement we could do.
These patches changed only error messages. Index and slice transforms
still use 0-based indexing.

--
Ticket URL: <https://code.djangoproject.com/ticket/29131#comment:7>

Reply all
Reply to author
Forward
0 new messages