2015-09-23 16:06:35 [HTTPChannel,439,127.0.0.1] 500 Error - /MAAS/settings/
Traceback (most recent call last):
File "/usr/lib/django16/django/core/handlers/wsgi.py", line 206, in __call__
response = self.get_response(request)
File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 236, in get_response
response = get_response(request)
File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 210, in get_response
return django_get_response(request)
File "/usr/lib/django16/django/core/handlers/base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
--- <exception caught here> ---
File "/usr/lib/django16/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 189, in view_atomic_with_post_commit_savepoint
return view_atomic(*args, **kwargs)
File "/usr/lib/django16/django/db/transaction.py", line 371, in inner
return func(*args, **kwargs)
File "/usr/lib/django16/django/contrib/auth/decorators.py", line 22, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/maasserver/views/settings.py", line 205, in settings
'boot_source', "Configuration updated.")
File "/usr/lib/python2.7/dist-packages/maasserver/views/__init__.py", line 219, in process_form
form.save()
File "/usr/lib/python2.7/dist-packages/maasserver/forms.py", line 1435, in save
boot_source.save()
File "/usr/lib/python2.7/dist-packages/maasserver/models/cleansave.py", line 37, in save
self.full_clean()
File "/usr/lib/django16/django/db/models/base.py", line 950, in full_clean
raise ValidationError(errors)
django.core.exceptions.ValidationError: {'url': [u'Enter a valid URL.']}
BootSourceSettings Model uses URLField and BootSourceSetti ngsForm does not (it uses CharField, which can be any string). So the form doesn't strip() nor does it check for URL formatting, then it tries to save() it into the Model and boom.
As an aside: I've noticed our Forms don't use any 'stripping' CharField (the default CharField doesn't do it for obvious reasons). Many of our string form fields SHOULD strip surrounding whitespace, since many of them are file paths, names, etc. Non-stripped whitespace could cause lots of problems, and even if it is user error, we should use the forms to clean these inputs up.
I've created and employed one for the other field on this Form (boot_source_ keyring, since it's a file path and shouldn't start or end with spaces).