tempurl PUT/upload throws AttributeError about dict_items

Bug #1929083 reported by Walter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Unassigned

Bug Description

A customer of ours was attempting to PUT files in a tempurl, which is supposed to be 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.

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/swift/+/792397

Changed in swift:
status: New → In Progress
Revision history for this message
Walter (wdoekes) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/swift/+/792485

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

Reviewed: https://review.opendev.org/c/openstack/swift/+/792397
Committed: https://opendev.org/openstack/swift/commit/77530136f13f1fc0d8625d43e1689427d4ee2fad
Submitter: "Zuul (22348)"
Branch: master

commit 77530136f13f1fc0d8625d43e1689427d4ee2fad
Author: Walter Doekes <email address hidden>
Date: Thu May 20 17:06:25 2021 +0200

    tempurl: Fix PUT upload to temp url on py3

    Without this change, the self._response_headers gets a dict_items() type
    on PUT. But the rest of the code assumes that it is a list.

    Bug manifestation:

        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'

    Closes-Bug: #1929083
    Change-Id: I5c398b6008716b64c668737e4201ba3b6ab3320b

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

Reviewed: https://review.opendev.org/c/openstack/swift/+/792485
Committed: https://opendev.org/openstack/swift/commit/6bfd93d88644f0a7ff979dc9d6c3d85fff42f632
Submitter: "Zuul (22348)"
Branch: master

commit 6bfd93d88644f0a7ff979dc9d6c3d85fff42f632
Author: Tim Burke <email address hidden>
Date: Thu May 20 15:32:50 2021 -0700

    symlink: Ensure headers are returned as a list on py3

    Change-Id: Ic2f4487b6caf81fef3455ce03dda2cc144ae24ec
    Related-Bug: #1929083
    Co-Authored-By: Walter Doekes <email address hidden>

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

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/swift/+/792655

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (stable/wallaby)

Related fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/swift/+/792656

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

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/swift/+/792657

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (stable/victoria)

Related fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/swift/+/792658

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

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/openstack/swift/+/792659

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (stable/ussuri)

Related fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/openstack/swift/+/792660

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

Fix proposed to branch: stable/train
Review: https://review.opendev.org/c/openstack/swift/+/792661

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (stable/train)

Related fix proposed to branch: stable/train
Review: https://review.opendev.org/c/openstack/swift/+/792662

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792655
Committed: https://opendev.org/openstack/swift/commit/24c086c8d072db9c77733b197e1e1b46a8989845
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 24c086c8d072db9c77733b197e1e1b46a8989845
Author: Walter Doekes <email address hidden>
Date: Thu May 20 17:06:25 2021 +0200

    tempurl: Fix PUT upload to temp url on py3

    Without this change, the self._response_headers gets a dict_items() type
    on PUT. But the rest of the code assumes that it is a list.

    Bug manifestation:

        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'

    Closes-Bug: #1929083
    Change-Id: I5c398b6008716b64c668737e4201ba3b6ab3320b
    (cherry picked from commit 77530136f13f1fc0d8625d43e1689427d4ee2fad)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792656
Committed: https://opendev.org/openstack/swift/commit/67a6ab152e2aa4d3c314fe9216de36cfa1d82603
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 67a6ab152e2aa4d3c314fe9216de36cfa1d82603
Author: Tim Burke <email address hidden>
Date: Thu May 20 15:32:50 2021 -0700

    symlink: Ensure headers are returned as a list on py3

    Change-Id: Ic2f4487b6caf81fef3455ce03dda2cc144ae24ec
    Related-Bug: #1929083
    Co-Authored-By: Walter Doekes <email address hidden>
    (cherry picked from commit 6bfd93d88644f0a7ff979dc9d6c3d85fff42f632)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792657
Committed: https://opendev.org/openstack/swift/commit/a8c2b46da624a2e133e5d6289529ba8ac63b2557
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit a8c2b46da624a2e133e5d6289529ba8ac63b2557
Author: Walter Doekes <email address hidden>
Date: Thu May 20 17:06:25 2021 +0200

    tempurl: Fix PUT upload to temp url on py3

    Without this change, the self._response_headers gets a dict_items() type
    on PUT. But the rest of the code assumes that it is a list.

    Bug manifestation:

        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'

    Closes-Bug: #1929083
    Change-Id: I5c398b6008716b64c668737e4201ba3b6ab3320b
    (cherry picked from commit 77530136f13f1fc0d8625d43e1689427d4ee2fad)

tags: added: in-stable-victoria
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792658
Committed: https://opendev.org/openstack/swift/commit/92b79a4a36cd3918cf26c6a3803750120aba54c7
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit 92b79a4a36cd3918cf26c6a3803750120aba54c7
Author: Tim Burke <email address hidden>
Date: Thu May 20 15:32:50 2021 -0700

    symlink: Ensure headers are returned as a list on py3

    Change-Id: Ic2f4487b6caf81fef3455ce03dda2cc144ae24ec
    Related-Bug: #1929083
    Co-Authored-By: Walter Doekes <email address hidden>
    (cherry picked from commit 6bfd93d88644f0a7ff979dc9d6c3d85fff42f632)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792659
Committed: https://opendev.org/openstack/swift/commit/4a38f62b266759d5b077c1007c1f920ad3296715
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit 4a38f62b266759d5b077c1007c1f920ad3296715
Author: Walter Doekes <email address hidden>
Date: Thu May 20 17:06:25 2021 +0200

    tempurl: Fix PUT upload to temp url on py3

    Without this change, the self._response_headers gets a dict_items() type
    on PUT. But the rest of the code assumes that it is a list.

    Bug manifestation:

        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'

    Closes-Bug: #1929083
    Change-Id: I5c398b6008716b64c668737e4201ba3b6ab3320b
    (cherry picked from commit 77530136f13f1fc0d8625d43e1689427d4ee2fad)

tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792660
Committed: https://opendev.org/openstack/swift/commit/18d8c15f93a0969281c9758e9d089556d7e0e2eb
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit 18d8c15f93a0969281c9758e9d089556d7e0e2eb
Author: Tim Burke <email address hidden>
Date: Thu May 20 15:32:50 2021 -0700

    symlink: Ensure headers are returned as a list on py3

    Change-Id: Ic2f4487b6caf81fef3455ce03dda2cc144ae24ec
    Related-Bug: #1929083
    Co-Authored-By: Walter Doekes <email address hidden>
    (cherry picked from commit 6bfd93d88644f0a7ff979dc9d6c3d85fff42f632)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (stable/train)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792662
Committed: https://opendev.org/openstack/swift/commit/fa6edcc7e677418ee56158641c5bcbb6afe6f1e5
Submitter: "Zuul (22348)"
Branch: stable/train

commit fa6edcc7e677418ee56158641c5bcbb6afe6f1e5
Author: Tim Burke <email address hidden>
Date: Thu May 20 15:32:50 2021 -0700

    symlink: Ensure headers are returned as a list on py3

    Change-Id: Ic2f4487b6caf81fef3455ce03dda2cc144ae24ec
    Related-Bug: #1929083
    Co-Authored-By: Walter Doekes <email address hidden>
    (cherry picked from commit 6bfd93d88644f0a7ff979dc9d6c3d85fff42f632)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/train)

Reviewed: https://review.opendev.org/c/openstack/swift/+/792661
Committed: https://opendev.org/openstack/swift/commit/b2601fe3e8e91eb5c509813f246ed78a0f0db327
Submitter: "Zuul (22348)"
Branch: stable/train

commit b2601fe3e8e91eb5c509813f246ed78a0f0db327
Author: Walter Doekes <email address hidden>
Date: Thu May 20 17:06:25 2021 +0200

    tempurl: Fix PUT upload to temp url on py3

    Without this change, the self._response_headers gets a dict_items() type
    on PUT. But the rest of the code assumes that it is a list.

    Bug manifestation:

        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'

    Closes-Bug: #1929083
    Change-Id: I5c398b6008716b64c668737e4201ba3b6ab3320b
    (cherry picked from commit 77530136f13f1fc0d8625d43e1689427d4ee2fad)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.23.3

This issue was fixed in the openstack/swift 2.23.3 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.28.0

This issue was fixed in the openstack/swift 2.28.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.25.2

This issue was fixed in the openstack/swift 2.25.2 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift victoria-eom

This issue was fixed in the openstack/swift victoria-eom release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift wallaby-eom

This issue was fixed in the openstack/swift wallaby-eom release.

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.