SCdF opened a new issue #784: Passing "stub": false without passing the attachment causes an unknown_error URL: https://github.com/apache/couchdb/issues/784 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://admin:pass@localhost:5984/attachment-test {"ok":true} scdf at SCdF in ~ $ curl -X POST -H 'Content-Type: application/json' http://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://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 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
With regards, Apache Git Services
