Description
Recently design docs saving code on server side started doing javascript validation of design documents. So now when trying to save design document with syntactically invalid javascript UI fails badly with the following in logs:
[menelaus:warn] [2012-07-03 22:59:55] [n_0@127.0.0.1:<0.509.0>:menelaus_web:loop:309] Client-side error-report for user "Administrator" on node 'n_0@127.0.0.1':
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
Browser client XHR failure encountered. (age: 955) Diagnostic info:
s: {"url":"/couchBase/default/_design/dev_foo","isLocal":false,"global":true,"type":"PUT","contentType":"application/json","processData":true,"async":true,"accepts":
,"contents":{"xml":{},"html":{},"json":{},"script":{}},"responseFields":
{"xml":"responseXML","text":"responseText"},"converters":
{"text html":true},"jsonp":"callback","timeout":30000,"cache":false,"dataType":"json","data":"{\"_id\":\"_design/dev_foo\",\"_rev\":\"1-c2a79e11\",\"views\":{\"foo1\":{\"map\":\"function (doc
{\\n emit(doc._id, null);\\n}\"}}}","dataTypes":["text","json"],"crossDomain":false,"hasContent":true}
xhrStatus: error,
xhrReadyState: 4,
errMsg: Bad Request,
statusCode: 400,
responseText:
{"error":"invalid_design_document","reason":"Syntax error in the map function of the view `foo1': SyntaxError: Unexpected token
We need to add handling of this kind of error to design doc saving code and do something sensible on UI.