1. Marcin Kasperski
  2. mercurial_keyring
  3. Issues
Issue #34 wontfix

AssertionError: assert prompt == "/"

Dennis Schridde
created an issue

When I try to pull from a repository that requires authentication, mercurial aborts with an assertion.

$ hg pull -u
** unknown exception encountered, please report by visiting
**  http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3]
** Mercurial Distributed SCM (version 2.0.2)
** Extensions loaded: gpg, pager, graphlog, color, record, mq, fetch, rebase, purge, convert, hgsubversion, hggit, crecord, fastimport, keyring
Traceback (most recent call last):
  File "/usr/bin/hg", line 38, in <module>
    mercurial.dispatch.run()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 27, in run
    sys.exit(dispatch(request(sys.argv[1:])))
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 64, in dispatch
    return _runcatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 87, in _runcatch
    return _dispatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 684, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 466, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 184, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 373, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 184, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 107, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 738, in _runcommand
    return checkargs()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 692, in checkargs
    return cmdfunc()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 681, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 139, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/home/$USER/.local/hgext/hgsubversion/hgsubversion/wrappers.py", line 594, in generic
    return orig(ui, repo, *args, **opts)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 139, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/rebase.py", line 629, in pullrebase
    orig(ui, repo, *args, **opts)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 139, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/mq.py", line 3229, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 4226, in pull
    other = hg.peer(repo, opts, source)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 184, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/$USER/.local/hgext/hg-git/hggit/__init__.py", line 188, in peer
    newpeer = orig(uiorrepo, *args, **opts)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 104, in peer
    return repository(rui, path, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 93, in repository
    repo = _peerlookup(path).instance(ui, path, create)
  File "/home/$USER/.local/hgext/hgsubversion/hgsubversion/svnrepo.py", line 190, in instance
    return httppeer.instance(ui, url, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/httprepo.py", line 236, in instance
    inst._fetchcaps()
  File "/usr/lib/python2.7/dist-packages/mercurial/httprepo.py", line 57, in _fetchcaps
    self.caps = set(self._call('capabilities').split())
  File "/usr/lib/python2.7/dist-packages/mercurial/httprepo.py", line 169, in _call
    fp = self._callstream(cmd, **args)
  File "/usr/lib/python2.7/dist-packages/mercurial/httprepo.py", line 117, in _callstream
    resp = self.urlopener.open(req)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 890, in http_error_401
    url, req, headers)
  File "/usr/lib/python2.7/dist-packages/mercurial/url.py", line 429, in http_error_auth_reqed
    self, auth_header, host, req, headers)
  File "/home/$USER/.local/hgext/keyring/mercurial_keyring.py", line 389, in basic_http_error_auth_reqed
    return basic_http_error_auth_reqed.orig(self, authreq, host, req, headers)
  File "/usr/lib/python2.7/urllib2.py", line 865, in http_error_auth_reqed
    response = self.retry_http_basic_auth(host, req, realm)
  File "/usr/lib/python2.7/urllib2.py", line 871, in retry_http_basic_auth
    user, pw = self.passwd.find_user_password(realm, host)
  File "/home/$USER/.local/hgext/keyring/mercurial_keyring.py", line 383, in find_user_password
    return self._pwd_handler.find_auth(self, realm, authuri, req)
  File "/home/$USER/.local/hgext/keyring/mercurial_keyring.py", line 234, in find_auth
    pwd = password_store.get_http_password(keyring_url, user)
  File "/home/$USER/.local/hgext/keyring/mercurial_keyring.py", line 117, in get_http_password
    self._format_http_key(url, username))
  File "/usr/lib/python2.7/dist-packages/keyring/core.py", line 37, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/lib/python2.7/dist-packages/keyring/backend.py", line 199, in get_password
    assert prompt == "/"
AssertionError

Comments (4)

  1. Marcin Kasperski repo owner

    The exception is thrown by keyring library, not by mercurial_keyring extension. I maintain only the latter.

    Taking a quick look at the code, looks like some problem in implementation of „SecretServiceKeyring”. The appropriate snippet of code is:

            bus = dbus.SessionBus()
            service_obj = bus.get_object('org.freedesktop.secrets',
                '/org/freedesktop/secrets')
            service_iface = dbus.Interface(service_obj,
                'org.freedesktop.Secret.Service')
            unlocked, locked = service_iface.SearchItems(
                {"username": username, "service": service})
            _, session = service_iface.OpenSession("plain", "")
            no_longer_locked, prompt = service_iface.Unlock(locked)
            assert prompt == "/"
    

    (the last line fails), so looks like some D-Bus service returns to keyring library something it does not expect.

    I do not know D-Bus but by reading http://standards.freedesktop.org/secret-service/re01.html#org.freedesktop.Secret.Service.Unlock I understand, that Unlock method is allowed to return aither / or some specific token, so looks like this assert is wrong and at least in your specific environment keyring library should work differently.

    Feel free to report it to keyring library authors (likely here: https://bitbucket.org/kang/python-keyring-lib )

  2. Marcin Kasperski repo owner

    I resolve it as wontfix, as this can not be fixed in mercurial_keyring, must be fixed in keyring library itself.

    As workaround you may try reconfiguring keyring library to use different backend (like KDE Wallet or Gnome Keyring, both used to work without problems for me).

  3. Log in to comment