[openstack-dev] swiftclient report that header value 120 must be of type str or bytes, not <type 'int'>, the detail info is like the following

Tim Burke tim at swiftstack.com
Tue Aug 16 20:05:46 UTC 2016


This is the result of a fairly recent change in requests [1], released 8 Aug. While the enforcement of header-value types is fairly recent, they've documented since 2.0.1 that headers must be byte- or unicode-strings [2], and more recently clarified it in their quick start guide [3]. It looks like this has been addressed in smaug already [4], but I'd expect that you could downgrade requests to 2.10.0 while waiting for a new release of smaug.

[1] https://github.com/kennethreitz/requests/pull/3366
[2] https://github.com/kennethreitz/requests/blob/v2.0.1/docs/api.rst#behavioral-changes
[3] http://docs.python-requests.org/en/latest/user/quickstart/#custom-headers
[4] https://review.openstack.org/#/c/355427/

Tim

> On Aug 11, 2016, at 1:17 AM, zhangshuai <446077695 at qq.com> wrote:
> 
> 
> 2016-08-11 08:01:25.371
>  DEBUG keystoneclient.auth.identity.v2 [-] Making authentication request to http://127.0.0.1:5000/v2.0/tokens from (pid=30110) get_auth_ref /usr/local/lib/python2.7/dist-packages/keystoneclient/auth/identity/v2.py:87
> 
> 2016-08-11 08:01:28.786
>  DEBUG swiftclient [-] REQ: curl -i http://127.0.0.1:8080/v1/AUTH_819fc87a6b1648f1b8dff8a0d09a9c62/smaug -X PUT -H "Content-Length: 0" -H "X-Auth-Token: c11af1086dd14279..." from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:164
> 
> 2016-08-11 08:01:28.786
>  DEBUG swiftclient [-] RESP STATUS: 201 Created from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:165
> 
> 2016-08-11 08:01:28.787
>  DEBUG swiftclient [-] RESP HEADERS: {u'Date': u'Thu, 11 Aug 2016 08:01:28 GMT', u'Content-Length': u'0', u'Content-Type': u'text/html; charset=UTF-8', u'X-Trans-Id': u'tx931f23ce6e584cbe9894e-0057ac30d8'} from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:166
> 
> 2016-08-11 08:01:28.803
>  DEBUG swiftclient [-] REQ: curl -i http://127.0.0.1:8080/v1/AUTH_819fc87a6b1648f1b8dff8a0d09a9c62/leases -X PUT -H "Content-Length: 0" -H "X-Auth-Token: c11af1086dd14279..." from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:164
> 
> 2016-08-11 08:01:28.803
>  DEBUG swiftclient [-] RESP STATUS: 201 Created from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:165
> 
> 2016-08-11 08:01:28.804
>  DEBUG swiftclient [-] RESP HEADERS: {u'Date': u'Thu, 11 Aug 2016 08:01:28 GMT', u'Content-Length': u'0', u'Content-Type': u'text/html; charset=UTF-8', u'X-Trans-Id': u'tx8069168a9d5641728cab8-0057ac30d8'} from (pid=30110) http_log /usr/local/lib/python2.7/dist-packages/swiftclient/client.py:166
> 
> 2016-08-11 08:01:42.819
>  ERROR swiftclient [-] Header value 120 must be of type str or bytes, not <type 'int'>
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient Traceback (most recent call last):
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 1565, in _retry
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     service_token=self.service_token, **kwargs)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 1268, in put_object
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     conn.request('PUT', path, contents, headers)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 401, in request
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     files=files, **self.requests_args)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 384, in _request
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     return self.request_session.request(*arg, **kwarg)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     prep = self.prepare_request(req)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 390, in prepare_request
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     hooks=merge_hooks(request.hooks, self.hooks),
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 295, in prepare
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     self.prepare_headers(headers)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 409, in prepare_headers
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     check_header_validity(header)
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient   File "/usr/local/lib/python2.7/dist-packages/requests/utils.py", line 756, in check_header_validity
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient     "not %s" % (value, type(value)))
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient InvalidHeader: Header value 120 must be of type str or bytes, not <type 'int'>
> 
> 2016-08-11 08:01:42.819 TRACE swiftclient 
> 
> 2016-08-11 08:01:42.821 ERROR smaug.services.protection.provider [-] Load bank plugin: 'smaug-swift-bank-plugin' failed.
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list