Comment 0 for bug 1929083

Revision history for this message
Walter (wdoekes) wrote :

A customer of ours was attempting to PUT files in a tempurl, which is supposed to be legl legal according to "/info".

However, the PUT failed with this backtrace:

  Traceback (most recent call last):
    File "eventlet/wsgi.py", line 573, in handle_one_response
      result = self.application(self.environ, start_response)
    File "swift/common/middleware/catch_errors.py", line 145, in __call__
      return context.handle_request(env, start_response)
    File "swift/common/middleware/catch_errors.py", line 120, in handle_request
      self._response_headers.append(('X-Trans-Id', trans_id))
  AttributeError: 'dict_items' object has no attribute 'append'

The immediate cause is this:

- Append is attempted on something that is not a list

  self._response_headers = somedict.items()
  ...
  self._response_headers.append(('X-Trans-Id', trans_id))

That is not legal in python3 (it was in python2).

I checked for .items() candidates, and there are few. At least:

  swift/common/middleware/symlink.py:
    self._response_headers = response_header_dict.items()

  swift/common/middleware/tempurl.py:
    return headers.items()

And the latter makes the most sense, as the user was using the tempurl functionality.

And indeed, this patch fixes things:
```
--- swift/common/middleware/tempurl.py
+++ swift/common/middleware/tempurl.py
@@ -839,7 +839,7 @@ class TempURL(object):
                     if h.startswith(p):
                         del headers[h]
                         break
- return headers.items()
+ return list(headers.items())

 def filter_factory(global_conf, **local_conf):
```

Versions:

- swift 2.25.1, but according to git, nothing was changed between 2.25.1 and master
- python3.8, but that's irrelevant

Cheers,
Walter Doekes
OSSO B.V.