seveas / git-spindle

Abandoned command-line interface to GitHub and other central git services
Other
172 stars 35 forks source link

'git lab whoami' fails with "ValueError: too many values to unpack" #75

Closed jrbyrne closed 9 years ago

jrbyrne commented 9 years ago

I am seeing 'git lab whoami' fail in the following way:

$ git lab whoami
James Byrne (id 8)
Profile   https://gitlab.com/u/james.byrne
Email     james.byrne@example.com
Traceback (most recent call last):
  File "/usr/local/bin/git-lab", line 5, in <module>
    GitLab().main()
  File "/usr/local/lib/python2.7/dist-packages/gitspindle/__init__.py", line 233, in main
    func(opts)
  File "/usr/local/lib/python2.7/dist-packages/gitspindle/gitlab.py", line 606, in whoami
    self.whois(opts)
  File "/usr/local/lib/python2.7/dist-packages/gitspindle/gitlab.py", line 638, in whois
    algo, key = pkey.key.split()
ValueError: too many values to unpack

The issue appears to be that my public key (i.e. the value of pkey.key) has the three fields but the code is only expecting two. The value of pkey.key looks like this (with the bulk of the key replaced by '...'):

ssh-rsa AAB3...Q2tt james.byrne@example.com
seveas commented 9 years ago

Intriguing. Is this actually on gitlab.com or on your own instance? The title (your email address) should be in pkey.title, not pkey.key.

jrbyrne commented 9 years ago

This is our own server (GitLab 7.10.0), however I don't think that's significant. The value of pkey.key is exactly what I imported into GitLab (copied from my ~/.ssh/id_rsa.pub), and this includes my e-mail address. This is standard OpenSSH format.

seveas commented 9 years ago

I know it is the standard OpenSSH, but the GitLab api is not supposed to return it that way. The algorithm and key parts go in pkey.key and the title part goes in pkey.title. gitlab.com and gitlab 7.7.2 on my own server both do that, so I guess this is a new bug in 7.10.

Does pkey.title actually contain anything for your key? Does git lab public-keys work for you?

jrbyrne commented 9 years ago

Yes, pkey.title is also my e-mail address.

When you add a key in the GitLab GUI there are 'Title' and 'Key' boxes to fill in, so I'm guessing that pkey.title is returning what I entered in the 'Title' field, which was my e-mail address, and pkey.key is returning what I put in the 'Key' field, which was the whole of the public key.

seveas commented 9 years ago

Aha! What does that key look like in the git user's .ssh/authorized_keys?

jrbyrne commented 9 years ago

Like this (key abbreviated as before):

command="/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell key-3",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAA...Q2tt james.byrne@example.com

seveas commented 9 years ago

Thanks for all the debug output! I'd still say it's a bug in gitlab that it accepts this input, but that doesn't mean git lab should gratuitously fail. Fixed in e60d3be and released as 2.5