network_check crashed with InvalidURL in _set_hostport(): nonnumeric port: ' text'

Bug #751701 reported by fl_ori4n
46
This bug affects 6 people
Affects Status Importance Assigned to Milestone
checkbox (Ubuntu)
Fix Released
Medium
Daniel Manrique
Precise
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: checkbox

[Impact]
network_check crashes when an invalid http_proxy variable is set. Various other things would fail if the user has an invalid http_proxy, but this test should be robust enough to not crash with an exception in this case.

The fix from the development version simply handles the InvalidURL exception thrown, by adding it to an already-present exception-handling block. Essentially we already knew how to handle certain exceptions, and had code for that, but weren't catching InvalidURL.

[Test case]
- Run this command:
http_proxy='http://whatever.com: text' /usr/share/checkbox/scripts/network_check

-Expected result:
 - A dialog indicating http connection failed

Actual result:
- Exception stack trace ending with:
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: ' text'

[Regression potential]
We're just catching an exception that we weren't before, and it's raised only in cases where the given proxy URL *is* invalid. So the potential for regressions is virtually none.

ProblemType: CrashDistroRelease: Ubuntu 11.04
Package: checkbox 0.11.2
ProcVersionSignature: Ubuntu 2.6.38-7.39-generic 2.6.38
Uname: Linux 2.6.38-7-generic x86_64
NonfreeKernelModules: nvidia wl
Architecture: amd64
Date: Tue Apr 5 19:28:26 2011
ExecutablePath: /usr/share/checkbox/scripts/network_checkInstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Beta amd64 (20110330)
InterpreterPath: /usr/bin/python2.7
ProcCmdline: /usr/bin/python /usr/share/checkbox/scripts/network_check -a
ProcEnviron:
 LANGUAGE=fr_CH:fr:en_GB:en
 PATH=(custom, no user)
 LANG=fr_CH.UTF-8
 SHELL=/bin/bash
PythonArgs: ['/usr/share/checkbox/scripts/network_check', '-a']SourcePackage: checkbox
Title: network_check crashed with InvalidURL in _set_hostport(): nonnumeric port: ' text'
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare

Related branches

Revision history for this message
fl_ori4n (girard.florian) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in checkbox (Ubuntu):
status: New → Confirmed
Revision history for this message
James Tait (jamestait) wrote :

Also occurs in 12.04 alpha 2.

Changed in checkbox (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Daniel Manrique (roadmr) wrote :

I managed to reproduce the failure reported in the stack trace by setting an invalid http_proxy environment variable:

http_proxy='http://whatever.com: text' /usr/share/checkbox/scripts/network_check

This would indicate that people observing this problem have set an invalid http_proxy variable. I'd appreciate if people experiencing this bug would let me know what this command run on a terminal shows:

echo http_proxy

Anyway, I'll fix the code so it properly handles the thrown exception.

Changed in checkbox (Ubuntu):
assignee: nobody → Daniel Manrique (roadmr)
status: Confirmed → In Progress
milestone: none → ubuntu-12.10-beta-1
visibility: private → public
Daniel Manrique (roadmr)
Changed in checkbox (Ubuntu):
status: In Progress → Fix Committed
status: Fix Committed → Fix Released
Revision history for this message
Daniel Manrique (roadmr) wrote :

Note that for SRUing this fix to 0.13.x, the exception handling syntax needs to be adapted to Python2, as it was done Python3-style.

description: updated
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Please test proposed package

Hello fidji-florian, or anyone else affected,

Accepted checkbox into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/checkbox/0.13.8 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in checkbox (Ubuntu Precise):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Daniel Manrique (roadmr) wrote :

Hi,

I took a system with checkbox 0.13.7, and ran the command given in the test section, I get this:
Traceback (most recent call last):
  File "/usr/share/checkbox/scripts/network_check", line 64, in <module>
    sys.exit(main())
  File "/usr/share/checkbox/scripts/network_check", line 40, in main
    results[protocol] = check_url(value)
  File "/usr/share/checkbox/scripts/network_check", line 17, in check_url
    urllib2.urlopen(url)
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1146, in do_open
    h = http_class(host, timeout=req.timeout) # will parse host:port
  File "/usr/lib/python2.7/httplib.py", line 693, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.7/httplib.py", line 721, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: ' text'

Then I installed checkbox 0.13.8 from -proposed, ran the same command. I get nothing on the command line, and a small window pops up indicating the http connection failed (understandably, since the proxy is purposefully invalid). This is the correct behavior as indicated by the test case.

Just for kicks, I then set a valid proxy and ran with both checkbox 0.13.7 and checkbox 0.13.8. In both cases it said the connection failed, but that's because the URL they are trying to load no longer exists (see https://launchpad.net/bugs/1065855). This issue is orthogonal to the current bug; I manually modified the network_check script to point to a valid URL, and then it works fine (says HTTP Connection: Success). So the proposed fix is working as expected.

I'll mark verification-done based on the above.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Steve Langasek (vorlon) wrote :

Hello fidji-florian, or anyone else affected,

Accepted checkbox into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/checkbox/0.13.9 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: removed: verification-done
tags: added: verification-needed
Revision history for this message
Daniel Manrique (roadmr) wrote :

Testing checkbox 013.9, here's what I did:

1- With checkbox 0.13.7 installed, ran:

http_proxy='http://whatever.com: text' /usr/share/checkbox/scripts/network_check

Result: Error trace as seen in the original report.

2- With checkbox 0.13.7 installed, ran:

http_proxy='http://gamerunblock.com' /usr/share/checkbox/scripts/network_check

Result: OOPS, a gtk window saying failed to connect. This is because the script points to an invalid URL.

3- Checkbox 0.13.7, manually modified the script to point to a valid URL, ran :

http_proxy='http://gamerunblock.com' /usr/share/checkbox/scripts/network_check

Result: HTTP Connection: success

So the bad behavior in item 1 was observed. Now, with checkbox 013.9:

1- With checkbox 0.13.9 installed, ran:

http_proxy='http://whatever.com: text' /usr/share/checkbox/scripts/network_check

Result: GTK window saying HTTP connection: Failed. (THIS is the fix in action, so it works, yay!)

2- With checkbox 0.13.9 installed, ran:

http_proxy='http://gamerunblock.com' /usr/share/checkbox/scripts/network_check

Result: OOPS, a gtk window saying failed to connect. This is because the script points to an invalid URL.

3- Checkbox 0.13.9, manually modified the script to point to a valid URL, ran :

http_proxy='http://gamerunblock.com' /usr/share/checkbox/scripts/network_check

Result: HTTP Connection: success

So the proposed fix is working as expected. I'll set to verification-done.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Adam Conrad (adconrad) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package checkbox - 0.13.9

---------------
checkbox (0.13.9) precise-proposed; urgency=low

  * Updated fix for bug #1026614 which was missing some code.
  * Removed bad fix for bug 990133.

checkbox (0.13.8) precise-proposed; urgency=low

  * New upstream release (LP: #1061198)

  [Marc Tardif]
  * checkbox/dispatcher.py: Updated license to GPLv3 to be consistent with
    rest of Checkbox files (LP: #1049881)

  [Sylvain Pineau]
  * qt/frontend/qtfront.ui: Fixed the test purpose widget size to allow two
    lines of description (LP: #1032255)
  * scripts/camera_test, jobs/camera.txt.in: Added a 10s timeout to the camera
    still test (LP: #990133)

  [Daniel Manrique]
  * jobs/audio.txt.in: replaced gconfaudiosink by autoaudiosink (LP: #978895)
  * Instruct Chromium browser to accept file:// URLs so it can correctly
    open the checkbox submission.xml report (LP: #1026614)
  * scripts/network_check: InvalidURL exception is caught and handled more
    cleanly (LP: #751701)
  * Set the correct user (root) for fwts-wakealarm test (LP: #1004102)
  * Set correct user (root) for usb/storage-preinserted, so it works correctly
    on servers (LP: #1004131)

  [Nathan Williams]
  * scripts/network_check: Fixed exception handling in the absence of zenity
    (LP: #988260)
 -- Daniel Manrique <email address hidden> Tue, 20 Nov 2012 16:31:02 -0500

Changed in checkbox (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.