特定文档上的 CouchDB 错误:“HTTP 请求中的 function_clause 错误”

发布于 2024-11-14 13:31:52 字数 15062 浏览 3 评论 0原文

我有一个 CouchDB 数据库,在其中存储带有 PDF 和 PNG 附件的文档。将附件保存到特定文档后,尝试在浏览器中查看该文档时,显示功能会失败。浏览器中的消息是:

{"error":"unknown_error","reason":"function_clause"}

couch.log 中的错误是

[Wed, 08 Jun 2011 21:29:58 GMT] [error] [<0.106.0>] function_clause error in HTTP request

[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] Stacktrace: [{couch_httpd,doc_etag,
             [{'EXIT',
                  {{case_clause,
                       {[{<<"author">>,
                          [<<"Brian St. Claire-King">>,
                           <<"Eloy LaSanta">>]},
                         {<<"book_type">>,[<<"Roleplaying Game">>]},
                         {<<"date_added">>,[2011,6,7]},
                         {<<"date_published">>,2008},
                         {<<"genre">>,
                          [<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                         {<<"language">>,<<"English">>},
                         {<<"license">>,
                          [{[{<<"url">>,<<"http://www.lulu.com">>},
                             {<<"id">>,<<"4880508">>}]}]},
                         {<<"page_count">>,276},
                         {<<"publisher">>,<<"Vajra Enterprises">>},
                         {<<"subtitle">>,<<"The Role Playing Game">>},
                         {<<"system">>,[<<"Organic Rule Components">>]},
                         {<<"title">>,<<"KidWorld">>},
                         {<<"last_modified">>,
                          <<"2011-06-08T01:58:44.697Z">>},
                         {<<"publisher_url">>,
                          <<"http://www.vajraenterprises.com/">>}]}},
                   [{couch_btree,lookup,3},
                    {couch_btree,lookup_kpnode,5},
                    {couch_btree,lookup,2},
                    {couch_db,get_full_doc_info,2},
                    {couch_db,open_doc_int,3},
                    {couch_db,open_doc,3},
                    {couch_httpd_db,couch_doc_open,4},
                    {couch_httpd_show,maybe_open_doc,2}]}}]},
         {couch_httpd_show,show_etag,4},
         {couch_httpd_show,handle_doc_show,6},
         {couch_httpd_db,do_db_req,2},
         {couch_httpd,handle_request_int,5},
         {mochiweb_http,headers,5},
         {proc_lib,init_p_do_apply,3}]

[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] 127.0.0.1 - - 'GET' /bookshelf/_design/bookshelf_loader/_show/book/4ddbbd8f3fd780c65e03c0a5e901fd57 500

我只能猜测其中一个附件已损坏。我尝试在 Futon 测试套件中运行适用于附件的测试; “附件”测试运行了 12 多个小时但没有完成。

我只想删除该文档,但没有修订号,并且任何访问该文档的尝试都会失败。我尝试使用 cURL 查询 _all_docs 视图,但它被中途中断并出现错误:

{"id":"40af854814db1b4890c37c669a11de28","key":"40af854814db1b4890c37c669a11de28","value":{"rev":"4-ff85b5dbb2e4800ab4bfee81f32f0866"}}
curl: (56) Received problem 2 in the chunky parser

有什么方法可以在只知道 _id 而不是 _rev 的情况下删除有问题的文档(或其附件)?

编辑:我翻阅日志并发现最初的崩溃,如下所示:

[Wed, 08 Jun 2011 02:00:05 GMT] [error] [<0.679.0>] ** Generic server <0.679.0> terminating 
** Last message in was {update_docs,<0.4902.0>,
                       [[{doc,<<"4ddbbd8f3fd780c65e03c0a5e901fd57">>,
                             {4,
                              [<<81,240,217,60,28,224,204,196,19,243,27,
                                 111,230,88,90,205>>,
                               <<171,3,185,48,48,23,182,2,95,122,48,132,
                                 184,105,254,242>>,
                               <<69,27,210,166,21,121,125,192,47,237,187,
                                 37,74,195,109,22>>,
                               <<145,31,9,71,4,24,15,90,97,154,177,102,
                                 151,156,111,34>>]},
                             {[{<<"author">>,
                                [<<"Brian St. Claire-King">>,
                                 <<"Eloy LaSanta">>]},
                               {<<"book_type">>,[<<"Roleplaying Game">>]},
                               {<<"date_added">>,[2011,6,7]},
                               {<<"date_published">>,2008},
                               {<<"genre">>,
                                [<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                               {<<"language">>,<<"English">>},
                               {<<"license">>,
                                [{[{<<"url">>,<<"http://www.lulu.com">>},
                                   {<<"id">>,<<"4880508">>}]}]},
                               {<<"page_count">>,276},
                               {<<"publisher">>,<<"Vajra Enterprises">>},
                               {<<"subtitle">>,
                                <<"The Role Playing Game">>},
                               {<<"system">>,
                                [<<"Organic Rule Components">>]},
                               {<<"title">>,<<"KidWorld">>},
                               {<<"last_modified">>,
                                <<"2011-06-08T01:58:44.697Z">>},
                               {<<"publisher_url">>,
                                <<"http://www.vajraenterprises.com/">>}]},
                             [{att,<<"KidWorld_2010_for_pdf.pdf">>,
                                  <<"application/pdf">>,76729048,76729048,
                                  <<143,119,231,165,202,3,166,134,23,195,
                                    94,84,227,25,87,193>>,
                                  4,
                                  {<0.676.0>,[4280434790]},
                                  identity},
                              {att,<<"kidworld copy.png">>,
                                  <<"image/png">>,21674,21674,
                                  <<237,107,129,30,82,36,136,61,29,17,202,
                                    217,209,88,187,125>>,
                                  3,
                                  {<0.676.0>,[4280406118]},
                                  identity}],
                             false,[]}]],
                       [],false,false}
** When Server state == {db,<0.678.0>,<0.679.0>,nil,<<"1307486659185780">>,
                        <0.676.0>,<0.680.0>,
                        {db_header,5,2454,0,
                            {4280430351,{508,9}},
                            {4280431672,517},
                            nil,0,nil,nil,1000},
                        2454,
                        {btree,<0.676.0>,
                            {4280430351,{508,9}},
                            #Fun<couch_db_updater.7.69395062>,
                            #Fun<couch_db_updater.8.86519079>,
                            #Fun<couch_btree.5.124754102>,
                            #Fun<couch_db_updater.9.24674233>},
                        {btree,<0.676.0>,
                            {4280431672,517},
                            #Fun<couch_db_updater.10.90337910>,
                            #Fun<couch_db_updater.11.13595824>,
                            #Fun<couch_btree.5.124754102>,
                            #Fun<couch_db_updater.12.34906778>},
                        {btree,<0.676.0>,nil,
                            #Fun<couch_btree.0.83553141>,
                            #Fun<couch_btree.1.30790806>,
                            #Fun<couch_btree.2.124754102>,nil},
                        2454,<<"bookshelf">>,
                        "../var/lib/couchdb/bookshelf.couch",[],[],nil,
                        {user_ctx,null,[],undefined},
                        nil,1000,
                        [before_header,after_header,on_file_open],
                        false}
** Reason for termination == 
** {{case_clause,{[{<<"author">>,
                [<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
               {<<"book_type">>,[<<"Roleplaying Game">>]},
               {<<"date_added">>,[2011,6,7]},
               {<<"date_published">>,2008},
               {<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
               {<<"language">>,<<"English">>},
               {<<"license">>,
                [{[{<<"url">>,<<"http://www.lulu.com">>},
                   {<<"id">>,<<"4880508">>}]}]},
               {<<"page_count">>,276},
               {<<"publisher">>,<<"Vajra Enterprises">>},
               {<<"subtitle">>,<<"The Role Playing Game">>},
               {<<"system">>,[<<"Organic Rule Components">>]},
               {<<"title">>,<<"KidWorld">>},
               {<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
               {<<"publisher_url">>,
                <<"http://www.vajraenterprises.com/">>}]}},
[{couch_btree,modify_node,4},
 {couch_btree,modify_kpnode,6},
 {couch_btree,modify_node,4},
 {couch_btree,query_modify,4},
 {couch_btree,add_remove,3},
 {couch_db_updater,update_docs_int,5},
 {couch_db_updater,handle_info,2},
 {gen_server,handle_msg,5}]}


[Wed, 08 Jun 2011 02:00:06 GMT] [error] [<0.679.0>] {error_report,<0.33.0>,
{<0.679.0>,crash_report,
 [[{initial_call,{couch_db_updater,init,['Argument__1']}},
   {pid,<0.679.0>},
   {registered_name,[]},
   {error_info,
       {exit,
           {{case_clause,
                {[{<<"author">>,
                   [<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
                  {<<"book_type">>,[<<"Roleplaying Game">>]},
                  {<<"date_added">>,[2011,6,7]},
                  {<<"date_published">>,2008},
                  {<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                  {<<"language">>,<<"English">>},
                  {<<"license">>,
                   [{[{<<"url">>,<<"http://www.lulu.com">>},
                      {<<"id">>,<<"4880508">>}]}]},
                  {<<"page_count">>,276},
                  {<<"publisher">>,<<"Vajra Enterprises">>},
                  {<<"subtitle">>,<<"The Role Playing Game">>},
                  {<<"system">>,[<<"Organic Rule Components">>]},
                  {<<"title">>,<<"KidWorld">>},
                  {<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
                  {<<"publisher_url">>,
                   <<"http://www.vajraenterprises.com/">>}]}},
            [{couch_btree,modify_node,4},
             {couch_btree,modify_kpnode,6},
             {couch_btree,modify_node,4},
             {couch_btree,query_modify,4},
             {couch_btree,add_remove,3},
             {couch_db_updater,update_docs_int,5},
             {couch_db_updater,handle_info,2},
             {gen_server,handle_msg,5}]},
           [{gen_server,terminate,6},{proc_lib,init_p_do_apply,3}]}},
   {ancestors,[<0.678.0>,<0.675.0>]},
   {messages,[]},
   {links,[<0.678.0>]},
   {dictionary,[]},
   {trap_exit,true},
   {status,running},
   {heap_size,6765},
   {stack_size,24},
   {reductions,65012}],
  []]}}

这是我的 _show 函数。我没有任何 _update 函数。

function(doc, req) {  
  var ddoc = this;
  var Mustache = require("lib/mustache");
  var path = require("vendor/couchapp/lib/path").init(req);
  var indexPath = path.list('index','recent-books',{descending:true, limit:25});

  var data = {
    header : {
      index : indexPath,
      headerTitle : "Bookshelf"
    },
    scripts : {
        assets : path.asset()
    },
index : indexPath,
    pageTitle : doc ? "Edit: " + doc.title : "Create a new book",
    assets : path.asset(),
db : req.path[0]
  };

  if (doc) {
    data.doc = JSON.stringify(doc);
    data.author = doc.author;
    data.book_types = getCheckboxValues(bookTypeArray, doc.book_type);
    data.book_type_other = getOthers(bookTypeArray, doc.book_type);
    data.cover_image = getAttachmentName(doc._attachments, "image/png");
    data.date_added = getDateString(doc.date_added);        
    data.date_published = doc.date_published;
    data.edition = doc.edition;
    data.issue_number = doc.issue_number;
    data.file_name = getAttachmentName(doc._attachments, "application/pdf");
    data.genres = getCheckboxValues(genreArray, doc.genre);
    data.genre_other = getOthers(genreArray, doc.genre);
    data._id = doc._id;
    data.languages = getDropdownValues(languageArray, doc.language);
    data.licenses = getLicenses(doc.license);
    data.page_count = doc.page_count;
    data.publishers = getDropdownValues(publisherArray, doc.publisher);
    data.publisher_other = getOther(publisherArray, doc.publisher);
    data.publisher_url = doc.publisher_url;
    data._rev = doc._rev;
    data.subtitle = doc.subtitle;
    data.systems = getCheckboxValues(systemArray, doc.system);
    data.system_other = getOthers(systemArray, doc.system);
    data.tags = doc.tags;
    data.title = doc.title;
    data.version = doc.version;
  } else {
    data.doc = JSON.stringify({});
    data.date_added = getDateString();
    data.book_types = getCheckboxValues(bookTypeArray);
    data.languages = getDropdownValues(languageArray, "English");
    data.licenses = "http://www.drivethrurpg.com,";
    data.publishers = getDropdownValues(publisherArray);
    data.genres = getCheckboxValues(genreArray);
    data.systems = getCheckboxValues(systemArray);
  }
  return Mustache.to_html(ddoc.templates.edit, data, ddoc.templates.partials);
}

我没有粘贴所有相对简单的辅助函数(例如 getCheckboxValues),这些函数在 Couch 中存储的内容和屏幕上显示的内容之间进行转换,但如果您认为它们有用,我可以。

我终于能够访问旧视图并获取文档的 _rev。但是,使用 cURL 发出 DELETE 命令会导致与以前相同的“case_clause”错误。任何将新文档 PUT 或 POST 到数据库中的尝试都将无限期挂起,并且从那时起数据库将变得无法访问。 (幸运的是,我有一个备份副本,其中仍然有一个损坏的文件,但至少可以访问。)

I have a CouchDB database in which I store documents with PDF and PNG attachments. After saving an attachment on a particular document, the show function fails when trying to view that document in the browser. The message in the browser is:

{"error":"unknown_error","reason":"function_clause"}

The error in couch.log is

[Wed, 08 Jun 2011 21:29:58 GMT] [error] [<0.106.0>] function_clause error in HTTP request

[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] Stacktrace: [{couch_httpd,doc_etag,
             [{'EXIT',
                  {{case_clause,
                       {[{<<"author">>,
                          [<<"Brian St. Claire-King">>,
                           <<"Eloy LaSanta">>]},
                         {<<"book_type">>,[<<"Roleplaying Game">>]},
                         {<<"date_added">>,[2011,6,7]},
                         {<<"date_published">>,2008},
                         {<<"genre">>,
                          [<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                         {<<"language">>,<<"English">>},
                         {<<"license">>,
                          [{[{<<"url">>,<<"http://www.lulu.com">>},
                             {<<"id">>,<<"4880508">>}]}]},
                         {<<"page_count">>,276},
                         {<<"publisher">>,<<"Vajra Enterprises">>},
                         {<<"subtitle">>,<<"The Role Playing Game">>},
                         {<<"system">>,[<<"Organic Rule Components">>]},
                         {<<"title">>,<<"KidWorld">>},
                         {<<"last_modified">>,
                          <<"2011-06-08T01:58:44.697Z">>},
                         {<<"publisher_url">>,
                          <<"http://www.vajraenterprises.com/">>}]}},
                   [{couch_btree,lookup,3},
                    {couch_btree,lookup_kpnode,5},
                    {couch_btree,lookup,2},
                    {couch_db,get_full_doc_info,2},
                    {couch_db,open_doc_int,3},
                    {couch_db,open_doc,3},
                    {couch_httpd_db,couch_doc_open,4},
                    {couch_httpd_show,maybe_open_doc,2}]}}]},
         {couch_httpd_show,show_etag,4},
         {couch_httpd_show,handle_doc_show,6},
         {couch_httpd_db,do_db_req,2},
         {couch_httpd,handle_request_int,5},
         {mochiweb_http,headers,5},
         {proc_lib,init_p_do_apply,3}]

[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] 127.0.0.1 - - 'GET' /bookshelf/_design/bookshelf_loader/_show/book/4ddbbd8f3fd780c65e03c0a5e901fd57 500

I can only guess that one of the attachments is corrupt. I have tried running the tests in the Futon Test Suite that are applicable to attachments; the "attachments" test ran for over 12 hours without completing.

I would just delete the document but I don't have a revision number and any attempt to access that document fails. I tried querying the _all_docs view with cURL, but it was interrupted half-way with the error:

{"id":"40af854814db1b4890c37c669a11de28","key":"40af854814db1b4890c37c669a11de28","value":{"rev":"4-ff85b5dbb2e4800ab4bfee81f32f0866"}}
curl: (56) Received problem 2 in the chunky parser

Is there any way that I can delete the offending document (or its attachments) knowing only the _id and not the _rev?

Edit: I paged back through the log and found the initial crash, as below:

[Wed, 08 Jun 2011 02:00:05 GMT] [error] [<0.679.0>] ** Generic server <0.679.0> terminating 
** Last message in was {update_docs,<0.4902.0>,
                       [[{doc,<<"4ddbbd8f3fd780c65e03c0a5e901fd57">>,
                             {4,
                              [<<81,240,217,60,28,224,204,196,19,243,27,
                                 111,230,88,90,205>>,
                               <<171,3,185,48,48,23,182,2,95,122,48,132,
                                 184,105,254,242>>,
                               <<69,27,210,166,21,121,125,192,47,237,187,
                                 37,74,195,109,22>>,
                               <<145,31,9,71,4,24,15,90,97,154,177,102,
                                 151,156,111,34>>]},
                             {[{<<"author">>,
                                [<<"Brian St. Claire-King">>,
                                 <<"Eloy LaSanta">>]},
                               {<<"book_type">>,[<<"Roleplaying Game">>]},
                               {<<"date_added">>,[2011,6,7]},
                               {<<"date_published">>,2008},
                               {<<"genre">>,
                                [<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                               {<<"language">>,<<"English">>},
                               {<<"license">>,
                                [{[{<<"url">>,<<"http://www.lulu.com">>},
                                   {<<"id">>,<<"4880508">>}]}]},
                               {<<"page_count">>,276},
                               {<<"publisher">>,<<"Vajra Enterprises">>},
                               {<<"subtitle">>,
                                <<"The Role Playing Game">>},
                               {<<"system">>,
                                [<<"Organic Rule Components">>]},
                               {<<"title">>,<<"KidWorld">>},
                               {<<"last_modified">>,
                                <<"2011-06-08T01:58:44.697Z">>},
                               {<<"publisher_url">>,
                                <<"http://www.vajraenterprises.com/">>}]},
                             [{att,<<"KidWorld_2010_for_pdf.pdf">>,
                                  <<"application/pdf">>,76729048,76729048,
                                  <<143,119,231,165,202,3,166,134,23,195,
                                    94,84,227,25,87,193>>,
                                  4,
                                  {<0.676.0>,[4280434790]},
                                  identity},
                              {att,<<"kidworld copy.png">>,
                                  <<"image/png">>,21674,21674,
                                  <<237,107,129,30,82,36,136,61,29,17,202,
                                    217,209,88,187,125>>,
                                  3,
                                  {<0.676.0>,[4280406118]},
                                  identity}],
                             false,[]}]],
                       [],false,false}
** When Server state == {db,<0.678.0>,<0.679.0>,nil,<<"1307486659185780">>,
                        <0.676.0>,<0.680.0>,
                        {db_header,5,2454,0,
                            {4280430351,{508,9}},
                            {4280431672,517},
                            nil,0,nil,nil,1000},
                        2454,
                        {btree,<0.676.0>,
                            {4280430351,{508,9}},
                            #Fun<couch_db_updater.7.69395062>,
                            #Fun<couch_db_updater.8.86519079>,
                            #Fun<couch_btree.5.124754102>,
                            #Fun<couch_db_updater.9.24674233>},
                        {btree,<0.676.0>,
                            {4280431672,517},
                            #Fun<couch_db_updater.10.90337910>,
                            #Fun<couch_db_updater.11.13595824>,
                            #Fun<couch_btree.5.124754102>,
                            #Fun<couch_db_updater.12.34906778>},
                        {btree,<0.676.0>,nil,
                            #Fun<couch_btree.0.83553141>,
                            #Fun<couch_btree.1.30790806>,
                            #Fun<couch_btree.2.124754102>,nil},
                        2454,<<"bookshelf">>,
                        "../var/lib/couchdb/bookshelf.couch",[],[],nil,
                        {user_ctx,null,[],undefined},
                        nil,1000,
                        [before_header,after_header,on_file_open],
                        false}
** Reason for termination == 
** {{case_clause,{[{<<"author">>,
                [<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
               {<<"book_type">>,[<<"Roleplaying Game">>]},
               {<<"date_added">>,[2011,6,7]},
               {<<"date_published">>,2008},
               {<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
               {<<"language">>,<<"English">>},
               {<<"license">>,
                [{[{<<"url">>,<<"http://www.lulu.com">>},
                   {<<"id">>,<<"4880508">>}]}]},
               {<<"page_count">>,276},
               {<<"publisher">>,<<"Vajra Enterprises">>},
               {<<"subtitle">>,<<"The Role Playing Game">>},
               {<<"system">>,[<<"Organic Rule Components">>]},
               {<<"title">>,<<"KidWorld">>},
               {<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
               {<<"publisher_url">>,
                <<"http://www.vajraenterprises.com/">>}]}},
[{couch_btree,modify_node,4},
 {couch_btree,modify_kpnode,6},
 {couch_btree,modify_node,4},
 {couch_btree,query_modify,4},
 {couch_btree,add_remove,3},
 {couch_db_updater,update_docs_int,5},
 {couch_db_updater,handle_info,2},
 {gen_server,handle_msg,5}]}


[Wed, 08 Jun 2011 02:00:06 GMT] [error] [<0.679.0>] {error_report,<0.33.0>,
{<0.679.0>,crash_report,
 [[{initial_call,{couch_db_updater,init,['Argument__1']}},
   {pid,<0.679.0>},
   {registered_name,[]},
   {error_info,
       {exit,
           {{case_clause,
                {[{<<"author">>,
                   [<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
                  {<<"book_type">>,[<<"Roleplaying Game">>]},
                  {<<"date_added">>,[2011,6,7]},
                  {<<"date_published">>,2008},
                  {<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
                  {<<"language">>,<<"English">>},
                  {<<"license">>,
                   [{[{<<"url">>,<<"http://www.lulu.com">>},
                      {<<"id">>,<<"4880508">>}]}]},
                  {<<"page_count">>,276},
                  {<<"publisher">>,<<"Vajra Enterprises">>},
                  {<<"subtitle">>,<<"The Role Playing Game">>},
                  {<<"system">>,[<<"Organic Rule Components">>]},
                  {<<"title">>,<<"KidWorld">>},
                  {<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
                  {<<"publisher_url">>,
                   <<"http://www.vajraenterprises.com/">>}]}},
            [{couch_btree,modify_node,4},
             {couch_btree,modify_kpnode,6},
             {couch_btree,modify_node,4},
             {couch_btree,query_modify,4},
             {couch_btree,add_remove,3},
             {couch_db_updater,update_docs_int,5},
             {couch_db_updater,handle_info,2},
             {gen_server,handle_msg,5}]},
           [{gen_server,terminate,6},{proc_lib,init_p_do_apply,3}]}},
   {ancestors,[<0.678.0>,<0.675.0>]},
   {messages,[]},
   {links,[<0.678.0>]},
   {dictionary,[]},
   {trap_exit,true},
   {status,running},
   {heap_size,6765},
   {stack_size,24},
   {reductions,65012}],
  []]}}

This is my _show function. I don't have any _update functions.

function(doc, req) {  
  var ddoc = this;
  var Mustache = require("lib/mustache");
  var path = require("vendor/couchapp/lib/path").init(req);
  var indexPath = path.list('index','recent-books',{descending:true, limit:25});

  var data = {
    header : {
      index : indexPath,
      headerTitle : "Bookshelf"
    },
    scripts : {
        assets : path.asset()
    },
index : indexPath,
    pageTitle : doc ? "Edit: " + doc.title : "Create a new book",
    assets : path.asset(),
db : req.path[0]
  };

  if (doc) {
    data.doc = JSON.stringify(doc);
    data.author = doc.author;
    data.book_types = getCheckboxValues(bookTypeArray, doc.book_type);
    data.book_type_other = getOthers(bookTypeArray, doc.book_type);
    data.cover_image = getAttachmentName(doc._attachments, "image/png");
    data.date_added = getDateString(doc.date_added);        
    data.date_published = doc.date_published;
    data.edition = doc.edition;
    data.issue_number = doc.issue_number;
    data.file_name = getAttachmentName(doc._attachments, "application/pdf");
    data.genres = getCheckboxValues(genreArray, doc.genre);
    data.genre_other = getOthers(genreArray, doc.genre);
    data._id = doc._id;
    data.languages = getDropdownValues(languageArray, doc.language);
    data.licenses = getLicenses(doc.license);
    data.page_count = doc.page_count;
    data.publishers = getDropdownValues(publisherArray, doc.publisher);
    data.publisher_other = getOther(publisherArray, doc.publisher);
    data.publisher_url = doc.publisher_url;
    data._rev = doc._rev;
    data.subtitle = doc.subtitle;
    data.systems = getCheckboxValues(systemArray, doc.system);
    data.system_other = getOthers(systemArray, doc.system);
    data.tags = doc.tags;
    data.title = doc.title;
    data.version = doc.version;
  } else {
    data.doc = JSON.stringify({});
    data.date_added = getDateString();
    data.book_types = getCheckboxValues(bookTypeArray);
    data.languages = getDropdownValues(languageArray, "English");
    data.licenses = "http://www.drivethrurpg.com,";
    data.publishers = getDropdownValues(publisherArray);
    data.genres = getCheckboxValues(genreArray);
    data.systems = getCheckboxValues(systemArray);
  }
  return Mustache.to_html(ddoc.templates.edit, data, ddoc.templates.partials);
}

I didn't paste all of the relatively simple helper functions (e.g. getCheckboxValues) that translate between what is stored in Couch and what goes on the screen, but I can if you think they'd be salutary.

I was finally able to access an older view and get the _rev of the document. Issuing the DELETE command with cURL results in the same "case_clause" error as before, however. Any attempt to PUT or POST a new document into the database will hang indefinitely and the database becomes inaccessible from that point on. (Fortunately I have a backup copy, which still has the one corrupt file but is at least accessible.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月牙弯弯 2024-11-21 13:31:52

正如 @JasonSmith 在上面的评论中提到的,这有时可能是由 Javascript 中的错误引起的。我无意中将视图的 name 属性直接设置为函数而不是包含其映射和可选的归约函数的对象,从而偶然发现了同样的错误消息。又名

坏:

"views": {
    "test_view": "function (doc) { ... }"
 }

好:

"views": {
   "test_view": {
       "map": "function (doc) { ... }"
   }
}

As @JasonSmith mentioned in the comments above, this can sometimes be caused by a bug in your Javascript. I stumbled upon this same error message by accidentally setting a View's name property to a function directly rather than to an object containing its map and optional reduce functions. AKA

Bad:

"views": {
    "test_view": "function (doc) { ... }"
 }

Good:

"views": {
   "test_view": {
       "map": "function (doc) { ... }"
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文