Symbols & and ? in the name of a large object

Bug #1011636 reported by Edward
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-swiftclient
Fix Released
High
gholt
python-swiftclient (Ubuntu)
Fix Released
High
Unassigned

Bug Description

If I save an object that has symbols "&" or "?" in its name the swift does it rightly.

$ swift upload 1 "4&4.txt"
4&4.txt

But if I try to save an large object with these symbols in its name I get a message about error.

$ swift upload -S 10 2 "4&4.txt"
4&4.txt segment 0
Object PUT failed: http://localhost:8080/v1/AUTH_system/2/4%264.txt 400 Bad Request X-Object-Manifest must in the format container/prefix

But I've found that the segments of this file were created.

etregubov@ten:~/1$ swift list 2_segments
4&4.txt/1339422290.6/2/00000000

I've traced the swift and found that it doesn't create manifest file. But if swift are patched this patch:

diff --git a/common/constraints.py b/common/constraints.py
index 235dcca..f03589e 100644
--- a/common/constraints.py
+++ b/common/constraints.py
@@ -120,7 +120,7 @@ def check_object_creation(req, object_name):
             container, prefix = value.split('/', 1)
         except ValueError:
             pass
- if not container or not prefix or '?' in value or '&' in value or \
+ if not container or not prefix or \
                 prefix[0] == '/':
             return HTTPBadRequest(request=req,
                 body='X-Object-Manifest must in the format container/prefix')

all works right.

Edward (tensar920)
summary: - & and ? in name of large object
+ Symbols & and ? in the name of a large object
Edward (tensar920)
description: updated
Revision history for this message
Juan J. Martínez (jjmartinez) wrote :

Looks like I can't read your patch because of the name (launchpad returns error 400).

Can you rename the patch?

Revision history for this message
Edward (tensar920) wrote :
Revision history for this message
Edward (tensar920) wrote :

Yes, of course. I've renamed it. Now it is readed.

Revision history for this message
karpov (ikarpov-9) wrote :

Any hope this issue will be resolved in the reasonable time? It's a deal breaker for us. We can't transfer our old data because of this.

karpov (ikarpov-9)
Changed in swift:
status: New → Confirmed
Thierry Carrez (ttx)
Changed in swift:
importance: Undecided → High
Revision history for this message
Alan Pevec (apevec) wrote :

Bad Request for ? and & was added in
https://github.com/openstack/swift/commit/fa3c871f0b1544f859bacf38497580afd69ced0b

so gholt should probably chime in, before proposed patch is considered.

Revision history for this message
gholt (gholt) wrote :

Swift header values should be url encoded (so you can include newlines and such).

However, there is a bug where the x-object-manifest header isn't unquoted after splitting; around line 915 of the proxy/server.py at the moment:

        if 'x-object-manifest' in resp.headers:
            lcontainer, lprefix = \
                resp.headers['x-object-manifest'].split('/', 1)
            try:
                listing = list(self._listing_iter(lcontainer, lprefix,
                                req.environ))

etc.

I'll try to fix that up soon with a unit test for it; but if I don't get to it before someone else, I won't complain. :)

Revision history for this message
gholt (gholt) wrote :

Oh, and I guess this bug (or a duplicate spawned, however it's done) should be for python-swiftclient too, where it needs to url encode the header value.

gholt (gholt)
Changed in swift:
assignee: nobody → gholt (gholt)
status: Confirmed → In Progress
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/9149

Revision history for this message
gholt (gholt) wrote :

The companion fix to bin/swift is at https://review.openstack.org/#/c/9151/

With both fixes in place:

$ ls -l "4&4.txt"
-rw-r--r-- 1 gholt gholt 140 2012-06-28 23:40 4&4.txt

$ swift upload -S 10 2 "4&4.txt"
4&4.txt segment 0
4&4.txt segment 7
4&4.txt segment 6
4&4.txt segment 1
4&4.txt segment 8
4&4.txt segment 5
4&4.txt segment 9
4&4.txt segment 4
4&4.txt segment 2
4&4.txt segment 3
4&4.txt segment 13
4&4.txt segment 12
4&4.txt segment 11
4&4.txt segment 10
4&4.txt

$ swift list 2
4&4.txt

$ swift list 2_segments
4&4.txt/1340926847.0/140/00000000
4&4.txt/1340926847.0/140/00000001
4&4.txt/1340926847.0/140/00000002
4&4.txt/1340926847.0/140/00000003
4&4.txt/1340926847.0/140/00000004
4&4.txt/1340926847.0/140/00000005
4&4.txt/1340926847.0/140/00000006
4&4.txt/1340926847.0/140/00000007
4&4.txt/1340926847.0/140/00000008
4&4.txt/1340926847.0/140/00000009
4&4.txt/1340926847.0/140/00000010
4&4.txt/1340926847.0/140/00000011
4&4.txt/1340926847.0/140/00000012
4&4.txt/1340926847.0/140/00000013

$ swift stat 2 "4&4.txt"
       Account: AUTH_test
     Container: 2
        Object: 4&4.txt
  Content Type: text/plain
Content Length: 140
 Last Modified: Thu, 28 Jun 2012 23:45:40 GMT
          ETag: "98ac91c9c31bd2f7b12678f3c637cc19"
      Manifest: 2_segments/4%264.txt/1340926847.0/140/
    Meta Mtime: 1340926847.0
 Accept-Ranges: bytes
   X-Timestamp: 1340927140.38237

$ mv "4&4.txt" orig.txt

$ swift download 2 "4&4.txt"
4&4.txt

$ diff orig.txt "4&4.txt"

gholt (gholt)
tags: added: python-swiftclient
Revision history for this message
Chmouel Boudjnah (chmouel) wrote :

FYI: Greg has been working on this in https://review.openstack.org/#/c/9151/

Revision history for this message
gholt (gholt) wrote :

Chmouel, indeed I have. Please see my comments above. :P

To reiterate, the two patches required to fix this bug are:

https://review.openstack.org/9149
https://review.openstack.org/#/c/9151/

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

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

commit f2a61ab50ed755b0a3c8bf57bf6795d25ff47851
Author: gholt <email address hidden>
Date: Thu Jun 28 23:25:27 2012 +0000

    Fixed bug 1011636 with segmented objects

    The X-Object-Manifest header value should be url encoded to allow for
    "special" characters to be used. This fix decodes such encoding. A
    corresponding fix to python-swiftclient (and any other clients) needs
    to be made to url encode the header value when sending.

    I also fixed any pep8 1.3.1 violations I found in the test I modified
    to verify this.

    Change-Id: I67f23dec1dc95ee37354dfdd9897f34758135ee6

Changed in swift:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
affects: swift → python-swiftclient
Revision history for this message
gholt (gholt) wrote :

ttx: This affects both swift and swiftclient. I couldn't make a sibling bug on swiftclient before, but now that we can should we instead do that?

karpov (ikarpov-9): Did you get to try this out to resolve your immediate issues?

Revision history for this message
Guillaume Dondero (gdondero) wrote :

gholt : yes it fix the problem, thanks a lot

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Fix problem with ampersend and question mark in the name of a large object.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
James Page (james-page)
Changed in swift (Ubuntu):
status: New → Triaged
importance: Undecided → High
Chuck Short (zulcss)
affects: swift (Ubuntu) → python-swiftclient (Ubuntu)
Chuck Short (zulcss)
Changed in python-swiftclient (Ubuntu):
status: Triaged → Fix Released
Changed in python-swiftclient:
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.