Bug 31006 - InvalidURL: nonnumeric port
InvalidURL: nonnumeric port
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Update - univention-updater
UCS 3.1
Other Linux
: P5 normal (vote)
: UCS 4.1
Assigned To: Philipp Hahn
Sönke Schwardt-Krummrich
: interim-2
Depends on: 39306
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-10 08:37 CEST by Tim Petersen
Modified: 2015-11-17 12:11 CET (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Ticket number:
Bug group (optional): Error handling, External feedback
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Petersen univentionstaff 2013-04-10 08:37:12 CEST
Due to a quite stupid copy&paste error I had a full url in repository/online/server (including slashes and stuff like that ;) ) which leads to a traceback while parsing.

"
root@master:~# univention-upgrade 

Starting univention-upgrade. Current UCS version is 3.1-0 errata82

Checking for local repository:                          none
An error occurred - stopping here.
"

updater.log:
#######################################################################
"
Traceback (most recent call last):
  File "/usr/sbin/univention-upgrade", line 353, in main
    performUpdate(options.updateto, ignoressh=options.ignoressh, ignoreterm=options.ignoreterm, interactive=not options.noninteractive, silent=False)
  File "/usr/sbin/univention-upgrade", line 129, in performUpdate
    updater = UniventionUpdater()
  File "/usr/lib/pymodules/python2.6/univention/updater/tools.py", line 522, in __init__
    self.ucr_reinit()
  File "/usr/lib/pymodules/python2.6/univention/updater/tools.py", line 578, in ucr_reinit
    assert self.server.access('/univention-repository/')
  File "/usr/lib/pymodules/python2.6/univention/updater/tools.py", line 403, in access
    res = UCSHttpServer.opener.open(req)
  File "/usr/lib/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 1184, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1130, in do_open
    h = http_class(host, timeout=req.timeout) # will parse host:port
  File "/usr/lib/python2.6/httplib.py", line 661, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.6/httplib.py", line 686, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
InvalidURL: nonnumeric port: ''
"
#######################################################################

After looking for bugs which describe this error message "An error occurred - stopping here." it seems that this is shown every time a traceback occurs.

From my point of view at least this message should be improved.
"An unexpected error occured - please have a look at /var/log/univention/updater.log" or something like this.
Comment 1 Tim Petersen univentionstaff 2013-04-10 08:38:59 CEST
Perhaps even the exception message could be passed through?
Comment 2 Stefan Gohmann univentionstaff 2014-03-10 06:59:27 CET
This was also reported via UMC Traceback: Ticket #2014030321012616
Comment 3 Philipp Hahn univentionstaff 2015-10-26 17:35:37 CET
Good news: Since r64693 repository/{mirror,online{/component/*}}/server now accepts an URI like 'http://updates.software-univention.de/' or 'https://updates.software-univention.de:443/univention-repository/'. '*/port' and '*/prefix' are then ignored, as they are parsed from the URI.

I also changed the error message to print the file name.

r64866 | Bug #31006 Up: Improve error message

Package: univention-updater
Version: 11.0.4-2.1419.201510261725
Branch: ucs_4.1-0

r64868 | Bug #31006 Up: Improve error message CL 2
r64867 | Bug #31006 Up: Improve error message CL
 The fatal error message in <command>univention-upgrade</command> now references the logfile <filename>/var/log/univention/updater.log</filename> for further details (<u:bug>31006</u:bug>).
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2015-11-05 16:33:03 CET
root@master94:~# ucr set repository/online/server=\
                             'https://updates-test.software-univention.de:foo' 
Setting repository/online/server
File: /etc/apt/sources.list.d/20_ucs-online-component.list
File: /etc/apt/mirror.list
File: /etc/apt/sources.list.d/15_ucs-online-version.list
root@master94:~# univention-upgrade 

Starting univention-upgrade. Current UCS version is 4.1-0 errata0

Checking for local repository:                          none
An error occurred - see "/var/log/univention/updater.log" for details
root@master94:~# tail -n 22 /var/log/univention/updater.log 

Starting univention-upgrade. Current UCS version is 4.1-0 errata0

Checking for local repository:                          none
Traceback in univention-upgrade:
Traceback (most recent call last):
  File "/usr/sbin/univention-upgrade", line 499, in main
    performUpdate(options, silent=False)
  File "/usr/sbin/univention-upgrade", line 137, in performUpdate
    updater = UniventionUpdater()
  File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 579, in __init__
    self.ucr_reinit()
  File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 623, in ucr_reinit
    self.config_repository()
  File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 584, in config_repository
    self.repourl = UcsRepoUrl(self.configRegistry, 'repository/online')
  File "/usr/lib/pymodules/python2.7/univention/updater/repo_url.py", line 62, in __init__
    port = url.port
  File "/usr/lib/python2.7/urlparse.py", line 110, in port
    port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'foo'

root@master94:~# cat /etc/apt/sources.list.d/15_ucs-online-version.list
#Warning: This file is auto-generated and might be overwritten by
[…]
# An error occurred during the repository check. The error message:
#   Traceback (most recent call last):
#     File "<stdin>", line 13, in <module>
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 579, in __init__
#       self.ucr_reinit()
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 623, in ucr_reinit
#       self.config_repository()
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 584, in config_repository
#       self.repourl = UcsRepoUrl(self.configRegistry, 'repository/online')
#     File "/usr/lib/pymodules/python2.7/univention/updater/repo_url.py", line 62, in __init__
#       port = url.port
#     File "/usr/lib/python2.7/urlparse.py", line 110, in port
#       port = int(port, 10)
#   ValueError: invalid literal for int() with base 10: 'foo'
#

root@master94:~# ucr set repository/online/server='https:://updates-test.software-univention.de:foo' 
Setting repository/online/server
File: /etc/apt/sources.list.d/20_ucs-online-component.list
File: /etc/apt/mirror.list
File: /etc/apt/sources.list.d/15_ucs-online-version.list
root@master94:~# sed -nre '10,21p' /etc/apt/sources.list.d/15_ucs-online-version.list

# An error occurred during the repository check. The error message:
#   Traceback (most recent call last):
#     File "<stdin>", line 13, in <module>
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 579, in __init__
#       self.ucr_reinit()
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 652, in ucr_reinit
#       assert self.server.access(None, '')
#     File "/usr/lib/pymodules/python2.7/univention/updater/tools.py", line 488, in access
#       raise ConfigurationError(uri, reason)
#   ConfigurationError: Configuration error: host is unresolvable
#


I think this is ok for now, but later on we should add a rough check if the given URL seems to be valid (port is an integer, hostname is not empty, protocol is given, ...).

OK: code change
OK: functional test
OK: changelog.xml
Comment 5 Stefan Gohmann univentionstaff 2015-11-17 12:11:37 CET
UCS 4.1 has been released:
 https://docs.software-univention.de/release-notes-4.1-0-en.html
 https://docs.software-univention.de/release-notes-4.1-0-de.html

If this error occurs again, please use "Clone This Bug".