couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Osher E (JIRA)" <j...@apache.org>
Subject [jira] [Created] (COUCHDB-1528) send headers on a Show Function causes badarg error
Date Mon, 27 Aug 2012 13:28:07 GMT
Osher E created COUCHDB-1528:
--------------------------------

             Summary: send headers on a Show Function causes badarg error
                 Key: COUCHDB-1528
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1528
             Project: CouchDB
          Issue Type: Bug
          Components: Database Core, HTTP Interface
    Affects Versions: 1.2
         Environment: Windows XP sp3
            Reporter: Osher E


h2. send headers on a Show Function causes badarg error

h3. Request
{code}
http://dev.osg-worlds.com:5984/opm/_design/verset/_show/env_settings/goa-dev?callback=$r
{code}

h3. Response
{code}
500 Internal Server Error
Cache-Control:must-revalidate
Content-Length:44
Content-Type:text/plain; charset=utf-8
Date:Mon, 27 Aug 2012 13:22:14 GMT
Server:CouchDB/1.2.0 (Erlang OTP/R15B)

{"error":"unknown_error","reason":"badarg"}
{code}

h3. Log entries:
{code]
[Mon, 27 Aug 2012 12:58:50 GMT] [error] [<0.6956.3>] Badarg error in HTTP request
[Mon, 27 Aug 2012 12:58:50 GMT] [info] [<0.6956.3>] Stacktrace: [{erlang,binary_to_list,
                                  [{[{<<"Content-Type">>,
                                      <<"text/javascript">>}]}],
                                  []},
                                 {couch_httpd_external,
                                  '-parse_external_response/1-fun-0-',1,
                                  [{file,
                                    "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"},
                                   {line,157}]},
                                 {lists,map,2,
                                  [{file,"lists.erl"},{line,1173}]},
                                 {lists,map,2,
                                  [{file,"lists.erl"},{line,1173}]},
                                 {couch_httpd_external,
                                  '-parse_external_response/1-fun-1-',2,
                                  [{file,
                                    "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"},
                                   {line,156}]},
                                 {lists,foldl,3,
                                  [{file,"lists.erl"},{line,1197}]},
                                 {couch_httpd_external,
                                  send_external_response,2,
                                  [{file,
                                    "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"},
                                   {line,129}]},
                                 {couch_httpd_db,do_db_req,2,
                                  [{file,
                                    "d:/relax/couchdb/src/couchdb/couch_httpd_db.erl"},
                                   {line,230}]}]
{code}

h2. more info

h3. The show function
{code}
 function(doc, req){ 
        var u
          , urls = doc.uses
          , out = 
        [ req.query.callback || "OPM.start"
        , "({app:\"", doc.app || ""
        , "\",env:\"" , doc.env
        , "\",ver:" , doc._rev.substr(0,doc._rev.indexOf("-"))
        , ",uses:{"
        ];

        for (u in urls) 
            out.push(u,":\"",urls[u],"\"",",");
        out[out.length-1] = "}});";

        start({headers: {"Content-Type": "text/javascript"}});
        out.forEach(send)
    }
{code}

Tried also

{code}
        out = out.join("");

        return { 
          headers: 
            { "Content-Type"  : "text/javascript"
            , "Content-Length": out.length
            }
        , body: out
        }
{code}

and 
{code}
           { "Content-Type"  : "text/javascript; charset=utf-8"
            , "Content-Length": out.length
            }
{code}

got same result


h3. Sample document:
{code}
{
   "_id": "app1-dev",
   "_rev": "10-269755da4f2c8ed771d9b301ec7d6163",
   "env": "dev",
   "app": "app1",
   "uses": {
       "front": "http://dev.server.com/front/",
       "auth": "http://qas.server.com/auth/",
       "back": "http://dev.server.com/back/"
   }
}
{code}

h3. configuration
produced with WindowsXP, couch 1.2.0, OTP R15.

I first noted the problem accessing through vhost + _rewrite. However, the problem is reproduced
also without.

*vhosts setting*
{code}
opm.dev.couch.com = /db/_design/app/_rewrite
{code}

*rewrite section*
{code}
  , rewrites : 
    [ {from:"/of/*", to:'_show/env_settings/*'}
    , {from:"/*"   , to:'*'}
    ]
{code}


h3. expected output (beautified)

{code}
  { app : "goa"
  , env : "dev"
  , ver : 10
  , uses: 
    { front: "http://dev.godofaxion.com/front/"
    , auth: "http://qas.godofaxion.com/auth/"
   , back: "http://dev.server.com/back/"
    }
  }
{code}




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message