Code review comment for lp:~leonardr/lazr.restful/missing-field-error

Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch fixes a small lazr.restful test failure that has been bothering me for about two weeks. I believe the failure was triggered by a new release of zope.schema or some other Zope component, but I haven't gone too deeply into it.

Here's what I think happened: when you tried to set a required field to None, Zope raises a RequiredMissing exception. It used to be that this exception had an empty string associated with it. lazr.restful caught ValidationError, the superclass of RequiredMissing, and substituted the generic string "Validation error" for the empty string.

Then, this new release of zope.schema (or whatever) happened, and now the RequiredMissing exception isn't created with an empty string. It's created with the name of the field that had the error. Since the string isn't empty, lazr.restful leaves it alone and you get the useless error "fieldname: fieldname".

To fix this I explicitly catch the RequiredMissing exception and put in the more useful error message "Missing required value".

« Back to merge proposal