Adding a boot image sync URL with an unqualified hostname fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Won't Fix
|
Medium
|
Unassigned | ||
python-django (Ubuntu) |
Triaged
|
Low
|
Unassigned |
Bug Description
I saw the following exception when trying to set my boot image sync URL to a URL in the format:
http://
Where 'host' was a valid hostname which would be resolved using the DNS search path (or hosts file).
When attempting to press "Save" on the settings screen, an internal server error was displayed, giving me no indication about what the problem was. The following exception was seen in the logs:
2015-04-01 18:35:58 [HTTPChannel,
Traceback (most recent call last):
File "/usr/lib/
response = self.get_
File "/usr/lib/
response = get_response(
File "/usr/lib/
return django_
File "/usr/lib/
response = self.handle_
--- <exception caught here> ---
File "/usr/lib/
response = wrapped_
File "/usr/lib/
return view_func(request, *args, **kwargs)
File "/usr/lib/
'boot_source', "Configuration updated.")
File "/usr/lib/
form.save()
File "/usr/lib/
boot_
File "/usr/lib/
self.
File "/usr/lib/
raise ValidationError
django.
It appears that, this being a Django URLField, the default validator is overly strict:
class URLValidator( RegexValidator) :
r'^(?: http|ftp) s?://' # http:// or https://
r'(?:( ?:[A-Z0- 9](?:[A- Z0-9-]{ 0,61}[A- Z0-9])? \.)+(?: [A-Z]{2, 6}\.?|[ A-Z0-9- ]{2,}\. ?)|' # domain...
r'localhost| ' # localhost...
r'\d{1, 3}\.\d{ 1,3}\.\ d{1,3}\ .\d{1,3} |' # ...or ipv4
r'\[?[ A-F0-9] *:[A-F0- 9:]+\]? )' # ...or ipv6
r'(?:: \d+)?' # optional port
r'(?:/ ?|[/?]\ S+)$', re.IGNORECASE)
regex = re.compile(
message = _('Enter a valid URL.')