[nightlies] oauthlib expects unicode values, int(timestamp) breaks webclient

Bug #1124061 reported by Roman Yepishev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Single Sign On Client
Status tracked in Trunk
Stable-4-2
Fix Released
Undecided
Unassigned
Trunk
Fix Released
High
dobey

Bug Description

STR:

1. Start ubuntuone-control-panel-qt in the terminal

Expected results:
It starts and displays data

Actual results:
It starts and hangs in "Loading informaiton" state.
The terminal has the following output:
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 422, in errback
    self._startRunCallbacks(fail)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 489, in _startRunCallbacks
    self._runCallbacks()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 576, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1127, in gotResult
    _inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1069, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
[...]
  File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/lib/python2.7/dist-packages/ubuntu-sso-client/ubuntu_sso/utils/webclient/qtnetwork.py", line 162, in request
    oauth_credentials)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1071, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python2.7/dist-packages/ubuntu-sso-client/ubuntu_sso/utils/webclient/common.py", line 192, in build_request_headers
    as_query=False)
  File "/usr/lib/python2.7/dist-packages/ubuntu-sso-client/ubuntu_sso/utils/webclient/common.py", line 175, in build_oauth_request
    {'Content-Type': 'application/x-www-form-urlencoded'})
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/__init__.py", line 234, in sign
    request.oauth_params.append(('oauth_signature', self.get_oauth_signature(request)))
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/__init__.py", line 81, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/__init__.py", line 155, in _render
    headers = parameters.prepare_headers(request.oauth_params, request.headers, realm=realm)
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "/usr/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable.')
exceptions.ValueError: Only unicode objects are escapable.

I dumped the value and parameters:
Name: u'oauth_nonce', value: u'149539723277074372841360757946'
Name: u'oauth_timestamp', value: 1360757946

The int timestamp is created in ubuntu_sso/utils/webclient/timestamp.py in get_faithful_time(). Patching it to return unicode(local_time + self.skew) instead of int(local_time + self.skew) fixes the issue.

Also note that since LP 872499 we are no longer checking the timestamps so it may be time to get rid of that code and simplify the timestamp creation.

Related branches

Roman Yepishev (rye)
Changed in ubuntu-sso-client:
assignee: nobody → Ubuntu One Client Engineering team (ubuntuone-client-engineering)
importance: Undecided → High
status: New → Triaged
tags: added: u1-by-dev u1-on-staging
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.