You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Simon Leblanc (JIRA)" <ji...@apache.org> on 2011/07/20 23:43:58 UTC

[jira] [Created] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

_update handler doesn't support slashes in doc _id
--------------------------------------------------

                 Key: COUCHDB-1229
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
             Project: CouchDB
          Issue Type: Bug
          Components: HTTP Interface
    Affects Versions: 1.1
            Reporter: Simon Leblanc


Let's say you have:

- a doc with _id foo/bar
- a show function named baz
- a update function named baz

Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.

This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Christopher Bonhage (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068686#comment-13068686 ] 

Christopher Bonhage commented on COUCHDB-1229:
----------------------------------------------

I encountered this as well; digging through src/couch_httpd_show.erl, handle_doc_show_req/3 appears to handle the "/" character in Document IDs properly:

DocParts = [DocId|Rest],
DocId1 = ?l2b(string:join([?b2l(P)|| P <- DocParts], "/")),

It seems like a bug that the _show handler joins the path parts back together, but the _update handler does not.

Obviously / is an important character in URL paths, but I don't see how that affects the trailing path parts here: database/_design/ddoc/_update/handler/docidpart1/docidpart2

Am I wrong?

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068690#comment-13068690 ] 

Paul Joseph Davis commented on COUCHDB-1229:
--------------------------------------------

Unfortunately, we don't just rely on "/" to distinguish between the dbname and docid. All of the doc handlers and and design handlers have come to rely on "/" as an important delimiter. Unfortunately some proxies unconditionally decode %2F to "/" before forwarding the URL so we also have some special cased logic to re-constitute things like design doc ids and what not.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Simon Leblanc (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087890#comment-13087890 ] 

Simon Leblanc commented on COUCHDB-1229:
----------------------------------------

Does this mean that slashes in docids will be supported?

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Christopher Bonhage (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christopher Bonhage updated COUCHDB-1229:
-----------------------------------------

    Attachment: COUCHDB-1229.patch

Patch for the _update handler to match the behavior of the _show handler with regards to slashes in docids

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Marcello Nuccio (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087929#comment-13087929 ] 

Marcello Nuccio commented on COUCHDB-1229:
------------------------------------------

I have the same problem as Christopher. URL rewriting works by splitting the path at "/", so they are a natural choice in docids: you get pretty urls and namespacing for free.

Does anyone have a better solution for this problem?

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jan Lehnardt reopened COUCHDB-1229:
-----------------------------------


I think I agree with Christopher et. al. here. Assigning this to myself.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068872#comment-13068872 ] 

Robert Newson commented on COUCHDB-1229:
----------------------------------------

"After the first "/" to separate the database from the document, there shouldn't be any need to treat "/" characters as being special."

Well, except for attachment urls, surely? /db_name/doc_id/attachment_name


> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Noah Slater (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068688#comment-13068688 ] 

Noah Slater commented on COUCHDB-1229:
--------------------------------------

Just to chime in, I do not see the logic here either. Specifically in regard to: "/ is an important character that distinguishes database resources from document resources, etc." After the first "/" to separate the database from the document, there shouldn't be any need to treat "/" characters as being special. Even a simple split on "/" would let you pull the first index to get the database name, while joining the remainder to reconstruct the docid.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068673#comment-13068673 ] 

Paul Joseph Davis commented on COUCHDB-1229:
--------------------------------------------

In genera, if you need to address a document with a slash in its name, you need to %2F escape the slash. There are a couple places where we relax this a bit by checking both cases. I'm not sure all the spots where we do this though.

Bottom line is that slashes in doc ids are just weird. Unless someone figures out a decent way to make them not weird while not breaking the rest of the API I don't see much changing in this regard.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Marcello Nuccio (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087634#comment-13087634 ] 

Marcello Nuccio commented on COUCHDB-1229:
------------------------------------------

Would it be wise then to forbid the creation of documents with "/" in the _id?

I thought it was supported because the designs documents have "/" in the _id. But if there are known problems, then I think the user should be promptly made aware of them.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Simon Leblanc (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068676#comment-13068676 ] 

Simon Leblanc commented on COUCHDB-1229:
----------------------------------------

Hum, too bad. I find this very useful.
I hesitated between using : or / as a separator and I went for / since it worked nicely with the rewrite handler.
I think either / should be allowed or we need a more powerful rewrite handler since not using slashes will make thing much more complicated for me…

Thanks for your answer!

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jan Lehnardt resolved COUCHDB-1229.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2
                   1.1.1

Added a test case and applied to trunk and 1.1.x

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>            Assignee: Jan Lehnardt
>              Labels: URI, id, update
>             Fix For: 1.1.1, 1.2
>
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Newson resolved COUCHDB-1229.
------------------------------------

    Resolution: Won't Fix

/ is an important character that distinguishes database resources from document resources, etc. Allowing it in doc ids unescaped is not likely any time soon.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Christopher Bonhage (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087909#comment-13087909 ] 

Christopher Bonhage commented on COUCHDB-1229:
----------------------------------------------

I disagree with this being a "Won't Fix". I am of the opinion that the _show handler has correct behavior here (and by extension, that the _update handler's swallowing of slashes in docids is incorrect behavior). The patch supplied above just duplicates the docid extraction routine from handle_doc_show_req/3 to handle_doc_update_req/3. 

My couchapps use slashes in docids to namespace documents, allowing me to use rewrite rules to force _show, _update, and _list handlers to only handle documents in a specified namespace. If slashes are not allowed in docids, this would not be possible (and would be a massive showstopper for me).

That being said, I do encounter some woes when it comes to trying to get attachments out of namespaced documents with rewrite rules (there's no way around escaping the %2F there), but that has nothing to do with the behavior of _show and _update handlers.

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (COUCHDB-1229) _update handler doesn't support slashes in doc _id

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jan Lehnardt reassigned COUCHDB-1229:
-------------------------------------

    Assignee: Jan Lehnardt

> _update handler doesn't support slashes in doc _id
> --------------------------------------------------
>
>                 Key: COUCHDB-1229
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1229
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1
>            Reporter: Simon Leblanc
>            Assignee: Jan Lehnardt
>              Labels: URI, id, update
>         Attachments: COUCHDB-1229.patch
>
>
> Let's say you have:
> - a doc with _id foo/bar
> - a show function named baz
> - a update function named baz
> Then _show/baz/foo/bar is valid but _update/baz/foo/bar is not. Only _update/baz/foo%2Fbar works.
> This is particularly annoying when you want to rewrite /something/* to _update/baz/foo/* (rewriting /something/* to _show/baz/foo/* works perfectly).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira