Opened 8 years ago

Closed 8 years ago

#25841 closed Bug (fixed)

ArrayField validation doesn't deal with its base field validation error message and params correctly.

Reported by: Wael BEN ZID EL GUEBSI Owned by: Simon Charette
Component: contrib.postgres Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the admin site when I entered a bad data for a postgres ArrayField, I got Http 500, my field is defined as bellow:

platforms = ArrayField(
        models.CharField(max_length=10, choices=PLATFORMS_CHOICES),
        verbose_name=_("Supported platforms")
)

You can see the traceback here

I also created validator for the platforms field, but it seems that the error happens before calling my validator

Change History (6)

comment:1 by Simon Charette, 8 years ago

Owner: set to Simon Charette
Status: newassigned
Triage Stage: UnreviewedAccepted

Confirmed with the latest Django 1.8 and master.

It looks like while django.contrib.postgres.forms.array.SimpleArrayField concatenates it's underlying field's error message it doesn't pass the original exception's parameters.

comment:2 by Simon Charette, 8 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set

Here's a proposed patch which is missing tests.

Could you confirm it fixes your issue?

comment:3 by Simon Charette, 8 years ago

Needs tests: unset
Patch needs improvement: unset

I'm pretty confident the patch does solve the reported issue.

comment:4 by Simon Charette, 8 years ago

Summary: Rendering errors in django admin site causes a HTTP 500ArrayField validation doesn't deal with its base field validation error message and params correctly.

comment:5 by Tim Graham, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Simon Charette <charette.s@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 3738e4a:

Fixed #25841 -- Handled base array fields validation errors with params.

Thanks to Trac alias benzid-wael for the report.

Note: See TracTickets for help on using tickets.
Back to Top