You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by mikewallace1979 <gi...@git.apache.org> on 2015/08/12 19:46:28 UTC

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

GitHub user mikewallace1979 opened a pull request:

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

    Return bad_request on view compilation error

    A request adding a non-compiling view was previously generating
    an HTTP 500 response. However, because the request is supplying an
    invalid view an HTTP 400 bad request response would be appropriate
    here. It would also make things clearer to the client that the
    fault lies within the request rather than the server.
    
    This commit updates the error returned on view compilation error
    to a {bad_request, compilation_error, Msg}. This will be converted
    into an HTTP 400 response by chttpd.
    
    Closes COUCHDB-2772

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

    $ git pull https://github.com/mikewallace1979/couchdb-couch 2772-http-400-on-view-compilation-error

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

    https://github.com/apache/couchdb-couch/pull/86.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 #86
    
----
commit 629e1553127a49f5891cd373eba4139ee54b11eb
Author: Mike Wallace <mi...@apache.org>
Date:   2015-08-12T17:38:19Z

    Return bad_request on view compilation error
    
    A request adding a non-compiling view was previously generating
    an HTTP 500 response. However, because the request is supplying an
    invalid view an HTTP 400 bad request response would be appropriate
    here. It would also make things clearer to the client that the
    fault lies within the request rather than the server.
    
    This commit updates the error returned on view compilation error
    to a {bad_request, compilation_error, Msg}. This will be converted
    into an HTTP 400 response by chttpd.
    
    Closes COUCHDB-2772

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/86#issuecomment-138282619
  
    See https://github.com/apache/couchdb-couch/pull/97


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by mikewallace1979 <gi...@git.apache.org>.
Github user mikewallace1979 closed the pull request at:

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


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by mikewallace1979 <gi...@git.apache.org>.
Github user mikewallace1979 commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/86#issuecomment-138289077
  
    Superseded by #97 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/86#issuecomment-130463047
  
    cc @davisp as well as he implemented this logic in 22fdbe2 and apache/couchdb-couch-index@fd046ec6 . May be we miss something tricky here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by mikewallace1979 <gi...@git.apache.org>.
Github user mikewallace1979 commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/86#issuecomment-130460908
  
    @kxepal I made the change in `couch_db:validate_ddoc` instead. Interestingly I had to wrap the validate call in a case because the validation function converts throws into tuples and returns them [1].
    
    That being the case should we also move the `invalid_design_doc` catch on L583 into a case clause?
    
    [1] https://github.com/apache/couchdb-couch-index/blob/master/src/couch_index_server.erl#L59-L60


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/86#issuecomment-130461484
  
    @mikewallace1979 Interesting. If `couch_index_server:validate/2` turns all the errors into retvals, then additional try/catch in `couch_db:validate_ddoc/2` is useless (almost). I think yes, better replace that try/catch with case then.
    
    @rnewson what you say?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Return bad_request on view compilation...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/86#discussion_r36910847
  
    --- Diff: src/couch_query_servers.erl ---
    @@ -41,7 +41,7 @@ try_compile(Proc, FunctionType, FunctionName, FunctionSource) ->
         catch {compilation_error, E} ->
             Fmt = "Compilation of the ~s function in the '~s' view failed: ~s",
             Msg = io_lib:format(Fmt, [FunctionType, FunctionName, E]),
    -        throw({compilation_error, Msg})
    +        throw({bad_request, compilation_error, Msg})
    --- End diff --
    
    I think you should change `couch_db:validate_ddoc` instead. Because this function may be called for the valid user request while complication will fail and then CouchDB will lie again.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---