'ValidationError' object has no attribute 'error_dict'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Fix Released
|
High
|
Mike Pontillo |
Bug Description
When attempting to create a network using invalid CIDR, "maas" cli returns a bad error message: this certainly makes it harder to figure out what you did wrong when using MAAS CLI.
$ maas maas1 subnets create name=192.
'ValidationError' object has no attribute 'error_dict'
(note how I mistyped cidr to be "192.168.122.0.24" instead of "/24").
This seems to be another instance of https:/
This is the full traceback in regiond.log: http://
I can easily "fix" this with http://
Related branches
- Blake Rouse (community): Approve
-
Diff: 107 lines (+20/-15)2 files modifiedsrc/maasserver/fields.py (+12/-12)
src/maasserver/tests/test_fields.py (+8/-3)
Changed in maas: | |
status: | New → Triaged |
importance: | Undecided → High |
milestone: | none → 2.2.0rc4 |
Changed in maas: | |
assignee: | nobody → Mike Pontillo (mpontillo) |
Changed in maas: | |
milestone: | 2.2.0rc4 → 2.2.0rc5 |
Changed in maas: | |
status: | Triaged → In Progress |
Changed in maas: | |
status: | In Progress → Fix Committed |
Changed in maas: | |
status: | Fix Committed → Fix Released |
milestone: | 2.2.0rc5 → 2.2.0 |
I thought about approaching this one by monkey-patching the Django ValidationError to either assert when this happens or automatically correct for this, but it since that single-string arguments to ValidationError are appropriate in some contexts, that didn't work out.
The next best thing, I think, is to make sure that all our custom database fields (such as CIDRField) raise a ValidationError using a dictionary, with the name of the field passed in as well.
This is a bit confusing because in the same file we also have custom *form* fields, which derive from a different class hierarchy. In /those/ implementations, using the single-string argument to ValidationError seems to be okay (and there's no way to get the field name anyway, since by then you just have a label).
So more investigation is needed to determine if we have a problem with the form fields as well, but as a first pass I can at least fix the database fields to correctly raise ValidationError.
I also feel like the database fields need to be split out into a separate file from the form fields.