Opened 3 years ago

Last modified 3 years ago

#23976 new Cleanup/optimization

ValidationError crashes if initialized with a list of empty dicts

Reported by: archivarius888 Owned by: nobody
Component: Core (Other) Version: master
Severity: Normal Keywords: exceptions, ValidationError
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by archivarius888)

Redefinition variable message by django/django/core/exceptions.py
line 114, for message in message:

below line, 116:

                if not isinstance(message, ValidationError):
                    message = ValidationError(message)
                self.error_list.extend(message.error_list)

if message isinstance of dict: AttributeError: 'ValidationError' object has no attribute 'error_list'

Change History (7)

comment:1 Changed 3 years ago by archivarius888

Description: modified (diff)

comment:2 Changed 3 years ago by Tim Graham

Could you provide the code to reproduce the error?

comment:3 Changed 3 years ago by archivarius888

>>> from django.core.exceptions import ValidationError
>>> ValidationError([{}])

comment:4 Changed 3 years ago by Huu Nguyen

Under what circumstances does this exception get thrown? From the definition of message, it doesn't appear that [{}] is a valid form of message. If message does take that form somehow, then that's a separate bug. Both ValidationError([]) and ValidationError({}) work just fine.

Last edited 3 years ago by Huu Nguyen (previous) (diff)

comment:5 Changed 3 years ago by archivarius888

Yeap, I just code would be better. And the user can do anything.

comment:6 Changed 3 years ago by Tim Graham

Component: Core (Serialization)Core (Other)
Severity: Release blockerNormal
Summary: ValidationError by list argumentValidationError crashes if initialized with a list of empty dicts
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

We could at least not crash so obscurely I suppose.

comment:7 Changed 3 years ago by Takis Issaris

Could not reproduce using current Django master on Python 3.4.1 on OSX 10.10.4.

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