Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing "stub": false without passing the attachment causes an unknown_error #784

Closed
SCdF opened this issue Aug 31, 2017 · 0 comments
Closed

Comments

@SCdF
Copy link

SCdF commented Aug 31, 2017

If you're uploading a document with attachments and you say it's not a stub without then also passing the attachment, you get an unfriendly error and an exception thrown in the log.

Expected Behavior

There should be a clean and readable error similar to when "stub": true and the attachment missing.

Current Behavior

You get {"error":"unknown_error","reason":"function_clause","ref":93628465} returned and the log shows:

[error] 2017-08-31T14:17:53.315121Z couchdb@localhost <0.23961.0> 6cdd28e8a6 req_err(93628465) unknown_error : function_clause
    [<<"base64:decode/1 L114">>,<<"couch_att:inline_from_json/2 L411">>,<<"couch_doc:-transfer_fields/2-lc$^0/1-2-/1 L235">>,<<"couch_doc:transfer_fields/2 L235">>,<<"couch_doc:from_json_obj_validate/1 L129">>,<<"chttpd_db:db_req/2 L328">>,<<"chttpd:process_request/1 L295">>,<<"chttpd:handle_request_int/1 L231">>]
[notice] 2017-08-31T14:17:53.315363Z couchdb@localhost <0.23961.0> 6cdd28e8a6 localhost:5984 127.0.0.1 undefined POST /attachment-test 500 ok 1

Steps to Reproduce (for bugs)

To follow along:

scdf at SCdF in ~
$ curl -X PUT http:https://admin:pass@localhost:5984/attachment-test
{"ok":true}
scdf at SCdF in ~
$ curl -X POST -H 'Content-Type: application/json' http:https://admin:pass@localhost:5984/attachment-test -d '{    "_id": "attachment-test",    "_attachments": {        "static/manifest.json": {            "content
_type": "application/json",            "digest": "md5-aFoQ0Neouur23mVxaLYoNA==",            "length": 30
3,            "revpos": 88,            "stub": true        }    }}'
{"error":"missing_stub","reason":"Invalid attachment stub in attachment-test for static/manifest.json"}
scdf at SCdF in ~
$ curl -X POST -H 'Content-Type: application/json' http:https://admin:pass@localhost:5984/attachment-test -d '{    "_id": "attachment-test",    "_attachments": {        "static/manifest.json": {            "content_type": "application/json",            "digest": "md5-aFoQ0Neouur23mVxaLYoNA==",            "length": 303,            "revpos": 88,            "stub": false        }    }}'
{"error":"unknown_error","reason":"function_clause","ref":93628465}

Note:

  • In the first POST I pass "stub": true and I get a nice error about not passing the attachment
  • In the second POST I changed stub from true to false, and we get the unfriendly "unknown_error" error message.

Your Environment

  • Version used: CouchDB 2.1.0
  • Operating System and version (desktop or mobile): MacOS 10.12.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant