3043: Always got 'bad credentials' when adding a github repository

qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
Aug. 7, 2013
What version are you running?

What's the URL of the page containing the problem?


What steps will reproduce the problem?
1.add repository
2.select github as hosting service
3.fill up account username/password
4.fill up all other required info
5.click save

What is the expected output? What do you see instead?
Always got "unable to link the account: bad credentials"

What operating system are you using? What browser?
rb server, ubuntu

Please provide any additional information below.
the log showed,

None - xxx - /reviews/admin/db/scmtools/repository/add/ - Internal Server Error: /reviews/admin/db/scmtools/repository/add/
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/contrib/admin/options.py", line 366, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/views/decorators/cache.py", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/contrib/admin/sites.py", line 196, in inner
    return view(request, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/utils/decorators.py", line 25, in _wrapper
    return bound_func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/utils/decorators.py", line 21, in bound_func
    return func(self, *args2, **kwargs2)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/db/transaction.py", line 224, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/contrib/admin/options.py", line 937, in add_view
    if form.is_valid():
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.7.11-py2.5.egg/reviewboard/scmtools/forms.py", line 937, in is_valid
    if not super(RepositoryForm, self).is_valid():
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/forms/forms.py", line 124, in is_valid
    return self.is_bound and not bool(self.errors)
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/forms/forms.py", line 115, in _get_errors
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.7.11-py2.5.egg/reviewboard/scmtools/forms.py", line 754, in full_clean
    super(RepositoryForm, self).full_clean()
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/forms/forms.py", line 271, in full_clean
  File "/usr/lib/python2.5/site-packages/Django-1.4.5-py2.5.egg/django/forms/forms.py", line 299, in _clean_form
    self.cleaned_data = self.clean()
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.7.11-py2.5.egg/reviewboard/scmtools/forms.py", line 790, in clean
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.7.11-py2.5.egg/reviewboard/scmtools/forms.py", line 582, in _clean_bug_tracker_info
AttributeError: 'NoneType' object has no attribute 'username'
#1 chipx86
Two things seem to be happening. First, we're not handling the failure case well at all. Second, GitHub is telling us that your login/password is invalid.

Can you verify that you are able to log into GitHub with that exact same login/password? If so, is there anything "special" about your password? Really odd characters, like Unicode characters?
  • +NeedInfo
#2 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
First, I didn't quite understand that 'link a new account' means linking to an existed account or linking to a unexisted account, in later case, github would create one for rb, by guess.

I tried either way, both failed.

1. For an existed account, got 'created' error returned by rb. I'm pretty sure login/pwd was correct, and only acsii letters and numbers inside.
2. For unexisted account, got 'bad credentials'

but the log showed same error 'NoneType' object has no attribute 'username' for both way.

P.S the browser is ff22, Windows 8 and Mac OSX 10.8
#3 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
I also tried another way.

1. Hosting service - none custom
2. Repo info, Git
              Path - a git url to github
              Raw file url mask - don't know how to set it, tried several
              User, Password - my github account
3. Publicly accessible
4. Uploaded my ssh key

Now the problem is diff may get generated, but can't diff in rb, error info

Diff currently unavailable.
Error: The patch to 'README.md' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.7QKhnj' for debugging purposes. `patch` returned: patching file /tmp/reviewboard.7QKhnj/tmpePd_8S Hunk #1 FAILED at 5. 1 out of 1 hunk FAILED -- saving rejects to file /tmp/reviewboard.7QKhnj/tmpePd_8S-new.rej 

Any hint? 

#4 chipx86
Yeah, you have to use GitHub in Hosting Service in order for diffs to render. It cannot work with Custom, because we need to use GitHub's API.

"Link a new account" is for establishing a new link in RB to a hosting service's account.

What's the "created" error?

When you say "an existed account," do you mean one already in the list, or one already on GitHub? If you don't have an item in the dropdown for your Account, then you do need to specify the GitHub login/password for your account that owns your repository.

If it's giving "bad credentials," then GitHub itself is saying that the username/password you typed is not a valid username/password on GitHub.

There will be a new UI in RB 1.8 that improves this entire process.
#5 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
okay, I just tried once more,

1. GitHub hosting service
2. Linked to my account already on Github, user/pwd
3. Associate my SSH key with the hosting service
4. save new repo

then got 'Unable to link the account: HTTP Error 201: Created'
server log said the same as first post, 'AttributeError: 'NoneType' object has no attribute 'username'' weird. 
#6 chipx86
HTTP 201 is not actually an error, but something thinks it is. The fact that it is indicates something outdated and confused is handling some aspect of this. It sounds like it's authenticating, but whatever is confused doesn't see that it succeeded.

What browser are you using?

What's your web server setup like?

It's also possible this is a Python 2.5 issue. What version of 2.5 exactly are you using?
#7 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
Firefox 22
I'm not the guy who set up the rb server, I'll check out with him.
The python version, did you mean python on server or client?
#8 chipx86
Python on the server. Some old versions of Python had bugs where valid HTTP 2xx errors appeared as errors.

Python 2.5 won't be supported for RB 1.8+, so it might be a good opportunity to do an upgrade.
#9 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
firefox 22 
python 2.5.2

I just tried chrome browser, failed too

What web server info do you need?

I'll upgrade python soon and try it out 
#10 chipx86
Don't worry about the web server info. I looked into this and it's definitely a bug in Python 2.5.x. That version of Python doesn't understand several successful HTTP 2xx errors as being successful.

We can work around this, and I can probably get a patch for you to apply in a day or two, but the best long-term solution is definitely an upgrade to Python 2.7.
#11 chipx86
Give this patch to Review Board a try and see if it works for you.
  • +
    From b18e7e7aa5a433e77af90621f658ba16f7439ba7 Mon Sep 17 00:00:00 2001
    From: Christian Hammond <chipx86@chipx86.com>
    Date: Thu, 1 Aug 2013 02:09:12 -0700
    Subject: [PATCH] Fix HTTP requests on Python 2.5.x.
    Python 2.5.x doesn't understand that all HTTP 2xx status codes are
    successful responses and not errors. This causes problems when using
    Python 2.5 and services like GitHub, which may return 2xx codes.
    This fix is not needed for Python 2.6+.
     reviewboard/hostingsvcs/service.py |   33 +++++++++++++++++++++++++++------
     1 file changed, 27 insertions(+), 6 deletions(-)
    diff --git a/reviewboard/hostingsvcs/service.py b/reviewboard/hostingsvcs/service.py
    index 9e6c8fa..610ad2d 100644
    --- a/reviewboard/hostingsvcs/service.py
    +++ b/reviewboard/hostingsvcs/service.py
    @@ -9,6 +9,24 @@ from django.utils.translation import ugettext_lazy as _
     from pkg_resources import iter_entry_points
    +class HTTPErrorProcessor(urllib2.HTTPErrorProcessor):
    +    """Processes HTTP error codes.
    +    Py
#12 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)

I’ll try upgrading python first and then your patch, tomorrow I’ll let you know the result.  
#13 chipx86
Just to note: An upgrade to a new major version of Python is not trivial. You will need to install the new version alongside 2.5 and get a new version of mod_wsgi (assuming you're using that for Apache), and reinstall Review Board and its dependencies.

What I'd recommend is trying this patch first, and get things working, assuming you have an existing install you need up-and-running quickly for your users.

Alongside that, best way to get set up with a newer version of Python is to install a newer LInux distro that comes with it. This will also help with some of our dependencies, especially going forward. You can then start to transition the server over.
#14 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
Sorry, how to apply the patch? I didn’t figure it out :(  
#15 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
I moved to /usr/lib/python2.5/site-packages/ReviewBoard-1.7.11-py2.5.egg  

then  patch -p0 < ~/rbpatch/0001-Fix-HTTP-requests-on-Python-2.5.x.patch

got 'can't find file to patch at input line 19’

server is ubuntu 10.04  
#16 qil****@gmai***** (Google Code) (Is this you? Claim this profile.)
It’s done, I had to manually input the service.py path  

Now I can do review over github and reviewboard.

Really appreciated!  
#17 david
Great. This patch will be in the next 1.7.x release.
  • -NeedInfo