bzr: ERROR: exceptions.KeyError: 'port' when branching ("Unable to handle http code 401: expected 200 or 404 for full response.")

Bug #564060 reported by Michael Rooney
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Undecided
Unassigned

Bug Description

Hello! I was trying to branch some code in SVN, https failed so I tried http, which resulted in an exception:

mrooney@mrooney-desktop:~/Code/hudson$ bzr branch https://svn.dev.java.net/svn/hudson/trunk/www
bzr: ERROR: Invalid http response for https://svn.dev.java.net/svn/hudson/trunk/www/.bzr/branch-format: Unable to handle http code 401: expected 200 or 404 for full response.
mrooney@mrooney-desktop:~/Code/hudson$ bzr branch http://svn.dev.java.net/svn/hudson/trunk/www
bzr: ERROR: exceptions.KeyError: 'port'

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    attaching the crash file
        /home/mrooney/.cache/crash/bzr-20100415174428-11632.crash
    and including a description of the problem.

    The crash file is plain text and you can inspect or edit it to remove
    private information.

Let me know if I can be of any more help, or if there is a workaround for this issue.

Traceback:
 Traceback (most recent call last):
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
     return the_callable(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
     ret = run(*run_argv)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
     return self.run_direct(**all_cmd_args)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
     return self._operation.run_simple(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
     self.cleanups, self.func, *args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
     result = func(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 1194, in run
     from_location)
   File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 958, in open_tree_or_branch
     bzrdir = klass.open(location)
   File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 843, in open
     return BzrDir.open_from_transport(t, _unsupported=_unsupported)
   File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 873, in open_from_transport
     redirected)
   File "/usr/lib/python2.6/dist-packages/bzrlib/lazy_import.py", line 125, in __call__
     return obj(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/__init__.py", line 1644, in do_catching_redirections
     return action(transport)
   File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 860, in find_format
     transport, _server_formats=_server_formats)
   File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 1820, in find_format
     return format.probe_transport(transport)
   File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/format.py", line 102, in probe_transport
     transport = get_svn_ra_transport(transport)
   File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/transport.py", line 142, in get_svn_ra_transport
     dav_entries = dav_options(bzr_transport, url)
   File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/transport.py", line 89, in dav_options
     resp = transport._perform(req)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib.py", line 79, in _perform
     response = self._opener.open(request)
   File "/usr/lib/python2.6/urllib2.py", line 397, in open
     response = meth(req, response)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1561, in http_response
     code, msg, hdrs)
   File "/usr/lib/python2.6/urllib2.py", line 429, in error
     result = self._call_chain(*args)
   File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
     result = func(*args)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 837, in http_error_302
     return self.parent.open(redirected_req)
   File "/usr/lib/python2.6/urllib2.py", line 397, in open
     response = meth(req, response)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1561, in http_response
     code, msg, hdrs)
   File "/usr/lib/python2.6/urllib2.py", line 429, in error
     result = self._call_chain(*args)
   File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
     result = func(*args)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1472, in http_error_401
     return self.auth_required(req, headers)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1084, in auth_required
     matching_handler = self.auth_match(server_header, auth)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1322, in auth_match
     user, password = self.get_user_password(auth)
   File "/usr/lib/python2.6/dist-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1185, in get_user_password
     port=auth['port'], path=auth['path'],
 KeyError: 'port'

Revision history for this message
Michael Rooney (mrooney) wrote :
Martin Pool (mbp)
description: updated
affects: bzr → bzr-svn
Revision history for this message
Thomas Krause (krause) wrote :

I can confirm that problem and it also occurs when you use a checkout instead of a branch. It first hit me when I upgraded to Ubuntu Lucid and all the repositories I used where unusable. You can try to force svn by using "svn+https://" instead of "https://" but this means you get prompted for your password and username all the time you want to do an update or a commit (you are actually prompted twice for an update...)

Changed in bzr-svn:
status: New → Confirmed
Revision history for this message
Thomas Krause (krause) wrote :

BTW I'm using the bzr and bzr-svn versions from the official repository, that means bzr 2.1.1 and bzr-svn 1.0.2

Revision history for this message
Thomas Krause (krause) wrote :

https://lists.ubuntu.com/archives/bazaar/2010q2/068655.html suggest that this problems occurs when pycurl is installed. Unfortunally this seems to be the case on every Ubuntu Lucid 10.04 desktop maschine since the "python-pycurl" package is required by gwibber (which is installed by default).

summary: - bzr: ERROR: exceptions.KeyError: 'port' when branching
+ bzr: ERROR: exceptions.KeyError: 'port' when branching ("Unable to
+ handle http code 401: expected 200 or 404 for full response.")
Revision history for this message
Thomas Krause (krause) wrote :

I forget to mention that I tried this workaround and it actually worked. Is there any way to make this happen with pycurl installed was well? Can I force bazaar to use urllib?

Ubuntu Lucid might be a quite common development platform for bazaar users, I hope not too many trap into this problem.

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 564060] Re: bzr: ERROR: exceptions.KeyError: 'port' when branching ("Unable to handle http code 401: expected 200 or 404 for full response.")

Hi Thomas,

On Sat, 2010-05-29 at 09:34 +0000, Thomas Krause wrote:
> I forget to mention that I tried this workaround and it actually worked.
> Is there any way to make this happen with pycurl installed was well? Can
> I force bazaar to use urllib?
I think if you use http+urllib it will, but the svn detection might not
kick in if you use that prefix. If that workaround works, please let us know. :-)

The proper fix is to have support for the OPTIONS HTTP request in Bazaar
core's transports and having bzr-svn just use that. We've done some
initial work on this but it's stalled since.

Cheers,

Jelmer

Revision history for this message
Thomas Krause (krause) wrote :

Hello Jelmer,

the trick to force bzr to use urllib with the https+urllib:// URL scheme works nice and the svn is properly detected.

Thanks a lot for your answer,

Thomas

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

as far as I can tell Request._perform should be taking caring of authentication, reassigning to bzr.

affects: bzr-svn → bzr
Revision history for this message
Martin Pool (mbp) wrote :

I think people are talking about two different bugs here. The one about 'KeyError: port' seems to be a dupe of bug 654684, in the main traceback, is now fixed. Is there another bug about handling http 401 over https vs http?

For now I'll dupe this; If there is another bug please dedupe and add a traceback from that (or just file another bug.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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