You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Jason Smith (Created) (JIRA)" <ji...@apache.org> on 2011/11/03 01:49:32 UTC

[jira] [Created] (COUCHDB-1330) provides() does not supports returning a status code or headers

provides() does not supports returning a status code or headers
---------------------------------------------------------------

                 Key: COUCHDB-1330
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
             Project: CouchDB
          Issue Type: Bug
          Components: JavaScript View Server
    Affects Versions: 1.1.1
         Environment: Iris Couch
            Reporter: Jason Smith
            Priority: Minor


An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers

This show function no longer works:

function (doc, req) {
    provides('html', function () {
        return {
            headers: { Location: 'http://www.iriscouch.com' },
            code: 302,
            body: 'Redirecting to IrisCouch website...'
        };
    });   
}

This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (COUCHDB-1330) provides() does not supports returning a status code or headers

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

Jason Smith updated COUCHDB-1330:
---------------------------------

    Attachment: A_0001-Support-provides-callbacks-indicating-status-code-an.patch

Patch with fix and unit tests
                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1330) provides() does not supports returning a status code or headers

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

Jason Smith commented on COUCHDB-1330:
--------------------------------------

Work is also in GitHub, https://github.com/jhs/couchdb/tree/COUCHDB-1330, note this is a patch against the 1.1.1 tag.
                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1330) provides() does not supports returning a status code or headers

Posted by "Nathan Vander Wilt (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215843#comment-13215843 ] 

Nathan Vander Wilt commented on COUCHDB-1330:
---------------------------------------------

This regression was introduced by https://github.com/apache/couchdb/commit/92f70219ce5ba487e4eb65dea7d16a9168a8547f#share/server/render.js for [#COUCHDB-1272] and also breaks returning "json" instead of "body". Jason's patch looks good to me for fixing it, and I'd love to see it applied soon.
                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1330) provides() does not supports returning a status code or headers

Posted by "Nathan Vander Wilt (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215849#comment-13215849 ] 

Nathan Vander Wilt commented on COUCHDB-1330:
---------------------------------------------

Just noticed one thing that might warrant further review by someone who understands the stack a little better:

Jason's patch will always set "provided_resp.body", potentially to an empty string. Could the presence of that (albeit empty) string conflict with provided_resp.json field at the Erlang level?
                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1330) provides() does not supports returning a status code or headers

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

Alexander Shorin commented on COUCHDB-1330:
-------------------------------------------

Oops, it looks like I'd break some things...My position was that provides functions are operates with data level, providing specific handler for requested content-type, while headers/status code is metadata that should be determent early. 

However, @Nathan right, there could be {"json": ...} body definition and also {"base64": ...} that processed behind of scene at CouchDB side.  Mixing them better to count as unexpectable result due to it depends on key order in json response from query server.

However, there is possible case for data collision:

function (doc, req) {
    provides('html', function () {
        return {
            headers: { Location: 'http://www.iriscouch.com' },
            code: 302,
            json: {status: 'redirecting', message: 'We will take you with us to IrisCouch!'}
        };
    });
  return {
    code: 404,
    headers: {"X-Couch-Reponse": "Relax!"}
    json: {error: 'not_a_chance', reason: "I'm tired, leave me alone!"}
  }
} 

What is expected output? 404 and error message or 302 and redirect? Should headers be merged or provided_resp one only wins? IMHO, provided_resp should override all resp data, except in case of chunked response when resp.body = resp.chunks +  resp.body + provided_resp.chunks + provided_resp.body.

If nobody stand against those terms I'll update patch to follow described behavior.
                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (COUCHDB-1330) provides() does not supports returning a status code or headers

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

Alexander Shorin updated COUCHDB-1330:
--------------------------------------

    Attachment: couchdb-1330.patch

I've ported fix from Python query server.


Current behavior: provides response could override everything from original one, but result body is still been merged by rules that I'd mentioned before:
> resp.body = resp.chunks + resp.body + provided_resp.chunks + provided_resp.body. 

                
> provides() does not supports returning a status code or headers
> ---------------------------------------------------------------
>
>                 Key: COUCHDB-1330
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1330
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1
>         Environment: Iris Couch
>            Reporter: Jason Smith
>            Priority: Minor
>         Attachments: A_0001-Support-provides-callbacks-indicating-status-code-an.patch, couchdb-1330.patch
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> An Iris Couch user lost the ability to redirect from a provides() callback in a show function: http://getsatisfaction.com/iriscouch/topics/_provides_method_not_returning_code_and_headers
> This show function no longer works:
> function (doc, req) {
>     provides('html', function () {
>         return {
>             headers: { Location: 'http://www.iriscouch.com' },
>             code: 302,
>             body: 'Redirecting to IrisCouch website...'
>         };
>     });   
> }
> This looks like a regression from 1.1.0; although there are no unit tests so perhaps strictly speaking it was unsupported functionality. Git bisect places the error at the patch to COUCHDB-1272.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira