Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-3286

Validation function throwing unexpected json crashes with function_clause

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Validation function expected to throw JSON object with types forbidden or unauthorized on invalid doc. If, however, it throws valid JSON error of different error type, that leads to crash with function_clause

       http post :5984/koi answer=42
      {
          "error": "unknown_error", 
          "reason": "function_clause", 
          "ref": 3462017963
      }
      

      In logs:

      [error] 2017-01-30T18:17:51.539256Z node1@192.168.50.50 <0.1685.0> 1c86018033 rpc couch_db:update_docs/4 {case_clause,{[{<<"bad_request">>,<<"Invalid document">>}]}} [{couch_qu
      ery_servers,validate_doc_update,5,[{file,"src/couch_query_servers.erl"},{line,285}]},{couch_db,'-validate_doc_update_int/3-lc$^0/1-0-',5,[{file,"src/couch_db.erl"},{line,642}]}
      ,{couch_db,'-validate_doc_update_int/3-fun-0-',3,[{file,"src/couch_db.erl"},{line,642}]},{couch_stats,update_histogram,2,[{file,"src/couch_stats.erl"},{line,98}]},{couch_db,'-p
      rep_and_validate_updates/6-fun-1-',3,[{file,"src/couch_db.erl"},{line,736}]},{lists,foldl,3,[{file,"lists.erl"},{line,1262}]},{couch_db,prep_and_validate_updates,6,[{file,"src/
      couch_db.erl"},{line,727}]},{couch_db,update_docs,4,[{file,"src/couch_db.erl"},{line,976}]}]
      

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user eiri opened a pull request:

          https://github.com/apache/couchdb-couch/pull/224

          Don't crash on unexpected validation's error type

          Validation function can throw JSON with error type different than forbidden or unauthorized.

          This patch makes couch return unknown_error instead of crashing query server.

          COUCHDB-3286

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/cloudant/couchdb-couch 82197-fix-validation_func-case_clause

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/couchdb-couch/pull/224.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #224


          commit 6412412ce76e42adb7b1f899f7eebc704b8d6416
          Author: Eric Avdey <eiri@eiri.ca>
          Date: 2017-01-30T19:27:59Z

          Don't crash on unexpected validation's error type

          Validation function can throw JSON with error
          type different than forbidden or unauthorized.

          This patch makes couch return unknown_error
          instead of crashing query server.

          COUCHDB-3286


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user eiri opened a pull request: https://github.com/apache/couchdb-couch/pull/224 Don't crash on unexpected validation's error type Validation function can throw JSON with error type different than forbidden or unauthorized. This patch makes couch return unknown_error instead of crashing query server. COUCHDB-3286 You can merge this pull request into a Git repository by running: $ git pull https://github.com/cloudant/couchdb-couch 82197-fix-validation_func-case_clause Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/224.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #224 commit 6412412ce76e42adb7b1f899f7eebc704b8d6416 Author: Eric Avdey <eiri@eiri.ca> Date: 2017-01-30T19:27:59Z Don't crash on unexpected validation's error type Validation function can throw JSON with error type different than forbidden or unauthorized. This patch makes couch return unknown_error instead of crashing query server. COUCHDB-3286
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6412412ce76e42adb7b1f899f7eebc704b8d6416 in couchdb-couch's branch refs/heads/master from Eric Avdey
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=6412412 ]

          Don't crash on unexpected validation's error type

          Validation function can throw JSON with error
          type different than forbidden or unauthorized.

          This patch makes couch return unknown_error
          instead of crashing query server.

          COUCHDB-3286

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6412412ce76e42adb7b1f899f7eebc704b8d6416 in couchdb-couch's branch refs/heads/master from Eric Avdey [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=6412412 ] Don't crash on unexpected validation's error type Validation function can throw JSON with error type different than forbidden or unauthorized. This patch makes couch return unknown_error instead of crashing query server. COUCHDB-3286
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/couchdb-couch/pull/224

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-couch/pull/224
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user eiri closed the pull request at:

          https://github.com/apache/couchdb/pull/451

          Show
          githubbot ASF GitHub Bot added a comment - Github user eiri closed the pull request at: https://github.com/apache/couchdb/pull/451

            People

            • Assignee:
              Unassigned
              Reporter:
              eiri Eric Avdey
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development