proxy-server Error: character mapping must return integer, None or unicode:

Bug #1242644 reported by Mehdi Abaakouk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Kun Huang

Bug Description

Hi,

I run tempest on a freshly installed packages in debian wheezy.

And tests around tempurl fail to compute the hmac in the tempurl middleware

(One of test that failed: tempest.api.object_storage.test_object_temp_url.ObjectTempUrlTest.test_put_object_using_temp_url)

The problem seems due that the HMAC key is 'unicode' instead of 'str'.

Here the error from the proxy-server daemon:

Oct 21 07:26:40 packages-va-wheezy-havana proxy-server Error: character mapping must return integer, None or unicode:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/catch_errors.py", line 37, in handle_request
    resp = self._app_call(env)
  File "/usr/lib/python2.7/dist-packages/swift/common/wsgi.py", line 388, in _app_call
    resp = self.app(env, self._start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/healthcheck.py", line 57, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/proxy_logging.py", line 268, in __call__
    iterable = self.app(env, my_start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/memcache.py", line 67, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/swob.py", line 1188, in _wsgify_self
    return func(self, Request(env))(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/slo.py", line 458, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/ratelimit.py", line 266, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/formpost.py", line 330, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/tempurl.py", line 278, in __call__
    hmac_vals = self._get_hmacs(env, temp_url_expires, keys)
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/tempurl.py", line 381, in _get_hmacs
    for key in keys]
  File "/usr/lib/python2.7/dist-packages/swift/common/middleware/tempurl.py", line 404, in _get_hmac
    env['PATH_INFO']), sha1).hexdigest()
  File "/usr/lib/python2.7/hmac.py", line 133, in new
    return HMAC(key, msg, digestmod)
  File "/usr/lib/python2.7/hmac.py", line 72,

Regards,
sileht

Revision history for this message
Kun Huang (academicgareth) wrote :

What's the values you stored in 'temp-url-key' and 'temp-url-key-2' as metadata?

Changed in swift:
assignee: nobody → Kun Huang (academicgareth)
Revision history for this message
Mehdi Abaakouk (sileht) wrote :

This is the one set by tempest in test tempest.api.object_storage.test_object_temp_url.ObjectTempUrlTest.test_put_object_using_temp_url (ie: 'Meta')

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/53048

Changed in swift:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/53048
Committed: http://github.com/openstack/swift/commit/abcecd26a7b5871f75f0fbddf0d08bbac95bb089
Submitter: Jenkins
Branch: master

commit abcecd26a7b5871f75f0fbddf0d08bbac95bb089
Author: Kun Huang <email address hidden>
Date: Wed Oct 23 21:19:01 2013 +0800

    utf8 encode tempurl key

    In tempurl middleware, hmac uses the value of account metadata to
    generate HMAC-SHA1 signature and hmac must accept a str-type string, not
    a unicode string. The meta dict returned from get_info stroges special
    chars as unicode however. So just encode it for tempurl using.

    Closes-Bug: #1242644
    Change-Id: I4be62eea014a573efc4748470de57dccf00e431d

Changed in swift:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (feature/ec)

Fix proposed to branch: feature/ec
Review: https://review.openstack.org/54029

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (feature/ec)
Download full text (24.9 KiB)

Reviewed: https://review.openstack.org/54029
Committed: http://github.com/openstack/swift/commit/94d3671b0bbf87fdbff845643963f3f9a97c58b5
Submitter: Jenkins
Branch: feature/ec

commit abcecd26a7b5871f75f0fbddf0d08bbac95bb089
Author: Kun Huang <email address hidden>
Date: Wed Oct 23 21:19:01 2013 +0800

    utf8 encode tempurl key

    In tempurl middleware, hmac uses the value of account metadata to
    generate HMAC-SHA1 signature and hmac must accept a str-type string, not
    a unicode string. The meta dict returned from get_info stroges special
    chars as unicode however. So just encode it for tempurl using.

    Closes-Bug: #1242644
    Change-Id: I4be62eea014a573efc4748470de57dccf00e431d

commit cd2e7df0b69bbd269cd3c4170e0fee8186a07c95
Author: Pete Zaitcev <email address hidden>
Date: Tue Oct 22 17:18:04 2013 -0600

    Add an __str__ method to brokers

    A few uses of broker.db_file are in printouts where we do need
    them, so the administrator may know what's up. Seems like an easy
    way to get rid of those is to make brokers identify themselves
    with common __str__. Alternative back-end implementations may
    supply something other than a filename here, for example a cluster
    name and a volume name.

    Note that I'm not sure if correct coercion would occur when
    brokers are bounced through dictionaries, hence explicit str().

    Change-Id: I329788ebd1fbe39ffadcf9f9d5194a74a88dde58

commit 9807a358c6d1314d25e3a41da75be5851fa0ac27
Author: Donagh McCabe <email address hidden>
Date: Fri Aug 23 15:03:08 2013 +0100

    Add WWW-Authenticate to 401 responses

    Per http://www.ietf.org/rfc/rfc2616.txt, when a 401 error is returned, the
    Www-Authenticate response header MUST also be returned. The format is
    described in http://www.ietf.org/rfc/rfc2617.txt.

    Swift supports and/or implements a number of authentication schemes
    including tempauth, Keystone, tempurl, formpost and container sync. In
    this fix, we use a catch-all, "Swift". The realm is the account (where
    known) or "unknown" (bad path or where the 401 is returned from code
    that does not have the request). Examples:

         Www-Authenticate: Swift realm="AUTH_1234567889"
         Www-Authenticate: Swift realm="unknown"

    Fixes bug #1215491

    Change-Id: I03362789318dfa156d3733ef9348795062a9cfc4

commit ed5101b2002b877518466ae5f9a6d652581238f2
Author: Yuan Zhou <email address hidden>
Date: Sat Oct 19 11:40:35 2013 +0800

    Adding more unit tests for audit_location_generator

    Change-Id: I40410fbbb79cea8647074f703e4675364c69d930

commit 5202b0e58613738cc81ec63e7c6da14ce5429526
Author: Peter Portante <email address hidden>
Date: Thu Sep 12 19:51:18 2013 -0400

    DiskFile API, with reference implementation

    Refactor on-disk knowledge out of the object server by pushing the
    async update pickle creation to the new DiskFileManager class (name is
    not the best, so suggestions welcome), along with the REPLICATOR
    method logic. We also move the mount checking and thread pool storage
    to the new ondisk.Devices object, which then also becomes th...

Changed in swift:
milestone: none → 1.11.0
Thierry Carrez (ttx)
Changed in swift:
status: Fix Committed → Fix Released
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.