couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Joseph Davis (JIRA)" <j...@apache.org>
Subject [jira] Updated: (COUCHDB-362) Malformed _attachments gives 500 and function_clause error
Date Sat, 09 Oct 2010 19:45:27 GMT

     [ https://issues.apache.org/jira/browse/COUCHDB-362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul Joseph Davis updated COUCHDB-362:
--------------------------------------

    Skill Level: Regular Contributors Level (Easy to Medium)

> Malformed _attachments gives 500 and function_clause error
> ----------------------------------------------------------
>
>                 Key: COUCHDB-362
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-362
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>         Environment: {"couchdb":"Welcome","version":"0.10.0a778641"}
>            Reporter: Brian Candler
>            Priority: Minor
>
> Creating a document with bad format of the _attachments structure gives a 500 error and
Erlang function_clause exceptions.
> ---- example 1 ----
> require 'rubygems'
> require 'restclient'
> require 'json'
> DB="http://127.0.0.1:5984/test"
> RestClient.delete DB rescue nil
> RestClient.put DB, {}.to_json
> doc = {"_id"=>"test","hello"=>"world","_attachments"=>{
>   "foo"=>["This is a test"].pack("m"),
> }}
> puts RestClient.post("#{DB}/_bulk_docs", {'docs'=>[doc],'all_or_nothing'=>true}.to_json)
> This aborts with 500 and logs:
> [Tue, 26 May 2009 10:14:53 GMT] [error] [<0.98.0>] Uncaught error in HTTP request:
{error,function_clause}
> [Tue, 26 May 2009 10:14:53 GMT] [info] [<0.98.0>] Stacktrace: [{couch_doc,'-transfer_fields/2-fun-0-',
>                         [{<<"foo">>,<<"VGhpcyBpcyBhIHRlc3Q=\n">>}]},
>              {lists,flatmap,2},
>              {couch_doc,transfer_fields,2},
>              {couch_httpd_db,'-db_req/2-fun-0-',1},
>              {lists,map,2},
>              {couch_httpd_db,db_req,2},
>              {couch_httpd_db,do_db_req,2},
>              {couch_httpd,handle_request,5}]
> [Tue, 26 May 2009 10:14:53 GMT] [info] [<0.98.0>] 127.0.0.1 - - 'POST' /test/_bulk_docs
500
> ---- example 2 ----
> require 'rubygems'
> require 'restclient'
> require 'json'
> DB="http://127.0.0.1:5984/test"
> RestClient.delete DB rescue nil
> RestClient.put DB, {}.to_json
> doc = {"_id"=>"test","hello"=>"world","_attachments"=>{
>   "foo"=>{"content_type"=>"text/plain","data"=>["This is a test"].pack("m")},
> }}
> puts RestClient.post("#{DB}/_bulk_docs", {'docs'=>[doc],'all_or_nothing'=>true}.to_json)
> This also aborts with 500 and logs:
> [Tue, 26 May 2009 10:16:10 GMT] [error] [<0.199.0>] Uncaught error in HTTP request:
{error,function_clause}
> [Tue, 26 May 2009 10:16:10 GMT] [info] [<0.199.0>] Stacktrace: [{couch_util,decode1,
>                          [<<"\n">>,
>                           <<84,104,105,115,32,105,115,32,97,32,116,101,115,
>                             116,1>>]},
>              {couch_doc,'-transfer_fields/2-fun-0-',1},
>              {lists,flatmap,2},
>              {couch_doc,transfer_fields,2},
>              {couch_httpd_db,'-db_req/2-fun-0-',1},
>              {lists,map,2},
>              {couch_httpd_db,db_req,2},
>              {couch_httpd_db,do_db_req,2}]
> [Tue, 26 May 2009 10:16:10 GMT] [info] [<0.199.0>] 127.0.0.1 - - 'POST' /test/_bulk_docs
500
> In this case, it seems only that the trailing newline in the base64 representation is
causing the error (adding a 'chomp' makes the program work). But it's not exactly a helpful
error message.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message