On 10/06/2015 10:52 AM, Pierre-Yves Chibon wrote:
On Tue, Oct 06, 2015 at 10:38:14AM -0400, Cole Robinson wrote:
> On 10/06/2015 03:24 AM, Pierre-Yves Chibon wrote:
>>> Does pkgdb use a bugzillarc file to store password values? python-bugzilla
has
>>> support for reading info from /etc/bugzillarc and ~/.bugzillarc, but
>>> admittedly I always forget it exists since it's from before my time
I've never
>>> been sure if anyone is actually using it.
>>>
>>> Maybe the bugzillarc file is setting the user/pass to literal 'None'
or similar.
>>
>> This would make sense indeed, but I just reproduced the bug again and I do not
>> have a ~/.bugzillarc
>>
>> $ ls ~/.bug*
>> /home/pingou/.bugwarriorrc
>> /home/pingou/.bugzillacookies
>> /home/pingou/.bugzillatoken
>>
>
> You hit the same error as the original report? That's strange to me then. Can
> you run the script I posted in the bug and paste the output?
Here it is:
$ python test.py
DEBUG:bugzilla:Detecting subclass for
https://bugzilla.redhat.com/xmlrpc.cgi
INFO:bugzilla:Using RHBugzilla for URL containing
bugzilla.redhat.com
INFO:bugzilla:Chose subclass RHBugzilla v0.1
DEBUG:bugzilla.base:Using tokenfile=/home/pingou/.bugzillatoken
DEBUG:bugzilla.base:Using cookiefile=/home/pingou/.bugzillacookies
DEBUG:bugzilla.base:Calling Bug.get with: {'extra_fields': ['comments',
'description', 'external_bugs', 'flags', 'sub_components',
'tags'], 'ids': [1267821]}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1):
bugzilla.redhat.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /xmlrpc.cgi HTTP/1.1" 200
None
Traceback (most recent call last):
File "test.py", line 7, in <module>
print bzapi.getbug(1267821)
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 1030, in
getbug
exclude_fields=exclude_fields, extra_fields=extra_fields)
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 1023, in
_getbug
extra_fields=extra_fields)[0]
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 995, in
_getbugs
r = self._proxy.Bug.get(getbugdata)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 168, in
_ServerProxy__request
ret = ServerProxy._ServerProxy__request(self, methodname, params)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 259, in
request
return self._request_helper(url, request_body)
File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 245, in
_request_helper
raise sys.exc_info()[1]
xmlrpclib.Fault: <Fault 32000: 'The cookies or token provide were not valid or
have expired. You may login again to get new cookies or a new token.'>
Okay, so that's the 'expected' error thrown by the new
bugzilla.redhat.com,
but notice it's only raised when you attempt the getbug() call. That's due to
expired credentials.
The unexpected one was the error raised by the Bugzilla() instantiation, which
is caused by the out of date bugzillarc.
>>>> After trying to replicate the issue in a python
shell, the exception seems to be
>>>> gone but another is thrown in:
>>>> File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line
1203, in query
>>>> r = self._query(query)
>>>> ...
>>>> Fault: <Fault 32000: 'The cookies or token provide were not valid
or have
>>>> expired. You may login again to get new cookies or a new token.'>
>>>>
>>>> Here as well, iirc it is possible to query a bug with python-bugzilla
without
>>>> being logged in, so I would not expect this exception.
>>>>
>>>
>>> Yes, this bit seems new from the
bugzilla.redhat.com side AFAICT. But
that's
>>> actually useful IMO; A common issue people have is that their credentials
>>> expire and it subtly changes the output of the bugzilla API... bugs stop
>>> showing up in queries since they are marked private, private info like
>>> qa_whiteboard disappears, etc. So if the user has an expired cached token I
>>> think it's better to bail out explicitly.
>>
>> I guess I only partly agree. I use .logged_in() to check if I am logged in and
>> I have scripts that for which the user do not need to be logged_in. The new
>> workflow breaks them if their credentials are invalid, but the script
doesn't
>> need these credentials. So, yes, I only partly agree and I would argue that the
>> script depending on the logged in status should check .logged_in().
>>
>
> Good point, but in the case when you know user doesn't need to be logged in,
> you can explicitly request the bugzilla API _not_ use cached credentials by doing
>
> bzapi = bugzilla.Bugzilla(url, cookiefile=None, tokenfile=None)
I'll keep that in mind, thanks for the pointer.
Though that makes me realize that even with those settings the bugzillarc file
will still be used... I'll probably add a use_credentials option to turn all
this stuff off with one setting for the next release.
- Cole