﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29318	ValidationError has no attribute `error_list` if message is a dict, but Field.run_validators() depends on it	Michael Käufl	nobody	"If the message is a dict, `ValidationError` has no attribute `error_list`:
{{{
class ValidationError(Exception):

    def __init__(self, message, code=None, params=None):
        # …
        if isinstance(message, dict):  # <----
            self.error_dict = {}
            for field, messages in message.items():
                if not isinstance(messages, ValidationError):
                    messages = ValidationError(messages)
                self.error_dict[field] = messages.error_list
        elif isinstance(message, list):
            self.error_list = …
            # …
        else:
            # …
            self.error_list = [self]

}}}
See
- https://github.com/django/django/blob/2.0.4/django/core/exceptions.py#L115-L137
- https://github.com/django/django/blob/c3055242c81812278ebdc93dd109f30d2cbd1610/django/core/exceptions.py#L115-L137 (current master)

But `Field.run_validators()` depends on `ValidationError` having an attribute `error_list`:

{{{
class Field(RegisterLookupMixin):

    def run_validators(self, value):
        # …
        for v in self.validators:
            try:
                v(value)
            except exceptions.ValidationError as e:
                if hasattr(e, 'code') and e.code in self.error_messages:
                    e.message = self.error_messages[e.code]
                errors.extend(e.error_list)  # <----

        # …
}}}

See
- https://github.com/django/django/blob/2.0.4/django/db/models/fields/__init__.py#L553-L567
- https://github.com/django/django/blob/c3055242c81812278ebdc93dd109f30d2cbd1610/django/db/models/fields/__init__.py#L577-L591 (current master)

This leads to an `AttributeError` when using a dict as message when raising a `ValidationError` inside a validator."	Bug	closed	Core (Other)	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
