Ticket #1763 (closed enhancement: fixed)

Opened 7 months ago

Last modified 7 months ago

Error messages for record validation in importData are too vague (patch provided)

Reported by: boutell Owned by: jwage
Priority: major Milestone: 1.0.6
Component: Attributes Version: 1.0.4
Severity: Keywords: fixtures
Cc: Has Test: no
Status: Pending Core Response Has Patch: yes

Description

When loading data from a fixtures file, such as a YAML file in a Symfony project, any sort of error in validation produces this highly generic message:

Validation error in class Page

The class name is the only hint given as to where the problem is.

Since the Doctrine CLI code catches all lower-level exceptions, calls getMessage() on them, and throws a new exception with only that information, it is not possible for higher-level application code to address this problem directly.

I have addressed it by upgrading the generateMessage() method of Doctrine_Validator_Exception (see attachment).

My version of generateMessage() provides:

The fields that failed validation The specific validation errors (for instance, "type") The first 50 characters of the first five fields of the record, for context

Example output:

Validation error in class Page

Errors in the following fields:

Field: title Errors: type

First five fields (for context):

id: title: I love trees

This makes debugging problems with fixtures files about 10,000% more practical.

Since there are no API changes I hope this can be included in the 1.0.x series where it could make a big difference in Doctrine's acceptance within Symfony, which relies heavily on the Doctrine CLI. There has been quite a bit of muttering about the opaqueness of validation error messages.

Attachments

gm (3.9 KB) - added by boutell 7 months ago.
generateMessage method of Doctrine_Validator_Exception, upgraded to provide details and context

Change History

Changed 7 months ago by boutell

  • attachment gm added

generateMessage method of Doctrine_Validator_Exception, upgraded to provide details and context

Changed 7 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [5300]) [1.0, 1.1] Improving error message when validation fails. (closes #1763)

Changed 7 months ago by jwage

  • milestone changed from 1.0.5 to 1.0.6
Note: See TracTickets for help on using tickets.