Why all my events are 'unlabeled event' and have Discarded invalid value for exception and breadcrumb?

I’m new to sentry, and just opened a trial account.
I’m using it in a Javascript projet, and all I’ve done so far is include this snippet :

<script src="https://cdn.ravenjs.com/3.7.0/raven.min.js"></script>
<script type="text/javascript">
    Raven.config('https://**@sentry.io/**').install()
</script>

In my account I get only one issue: unlabeled event, and all of them have this error notice:
There were 2 errors encountered while processing this event
Discarded invalid value for parameter 'exception’
Discarded invalid value for parameter ‘breadcrumb’

The content is valid JSON, the content of values itself is also valid JSON (see below for an example).

Is there something else I need to do to configure my account properly ? Or am I missing something else ?

Thanks for any help.

Detail of the exception:

{
  "name": "exception",
  "value": {
    "values": "[{\"type\":\"TypeError\",\"value\":\"d.deselectAll is not a function\",\"stacktrace\":{\"frames\":[{\"filename\":\"https://cdn.ravenjs.com/3.7.0/raven.min.js\",\"lineno\":2,\"colno\":4306,\"function\":\"d\",\"in_app\":false},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":120207,\"function\":\"Ext.EventManager</<.createListenerWrap/m\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js line 1 > Function\",\"lineno\":4,\"colno\":10,\"function\":\"anonymous\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":526492,\"function\":\".onClick\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":526671,\"function\":\".fireHandler\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":127213,\"function\":\".fireEvent\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":460232,\"function\":\".monitor/a.fireEventArgs\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":459398,\"function\":\".dispatch\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":111620,\"function\":\".fire\",\"in_app\":true},{\"filename\":\"http://romanel.bible.ch/mbgest2/app.js\",\"lineno\":1,\"colno\":1671236,\"function\":\".onOrdersPrintPdf\",\"in_app\":true}]}}]"
  }
}

Content of values:

[{
    "type":"TypeError",
    "value":"d.deselectAll is not a function",
    "stacktrace":{
    "frames":[
	{"filename":"https://cdn.ravenjs.com/3.7.0/raven.min.js","lineno":2,"colno":4306,"function":"d","in_app":false},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":120207,"function":"Ext.EventManager</<.createListenerWrap/m","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js line 1 > Function","lineno":4,"colno":10,"function":"anonymous","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":526492,"function":".onClick","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":526671,"function":".fireHandler","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":127213,"function":".fireEvent","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":460232,"function":".monitor/a.fireEventArgs","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":459398,"function":".dispatch","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":111620,"function":".fire","in_app":true},
	{"filename":"http://romanel.bible.ch/mbgest2/app.js","lineno":1,"colno":1671236,"function":".onOrdersPrintPdf","in_app":true}
    ]
    }
}]

You’ll notice that the ‘values’ param is a string, and not an array as expected (and required). We’ve seen this in some other situations, and frankly I have no answer as to why it could be happening.

/cc @benvinegar

Of note, there’s also something wrong with filename parsing in this stack:

	{"filename":"http://romanel.bible.ch/mbgest2/app.js line 1 > Function","lineno":4,"colno":10,"function":"anonymous","in_app":true},

Thanks, even if this is not quite satisfactory. I installed now the uncompressed version, and used it in debug mode (debug: true). The first result is:

  • in raven.js, line 1427 this._logDebug('debug', 'Raven about to send:', data);, data is correct (an object).
  • in the payload of the http request it is a Json.encoded string.

I’ll post again if I have more information.

Here is the problem: I use mootools.
JSON.stringify internally calles Array.toJSON(), and this is overridden by the mootools framework as :

Array.prototype.toJSON
function(){return JSON.encode(this);} 

The solution is to define stringify the mootools way and not use JSON.stringify():

function stringify(obj, replacer, spaces, cycleReplacer) {
    return JSON.encode(obj)
}

Or the ExtJS way:

function stringify(obj, replacer, spaces, cycleReplacer) {
    return Ext.encode(obj)
}

@zeeg, thanks for your help.

The solution is to define stringify the mootools way and not use JSON.stringify():

Is this your solution (i.e. is this resolved)? Or is this a suggestion for us to change something in raven-js?

I think we should explore if there’s something we could do to prevent this from happening in the JS SDK.

Yes, this is resolved.
Both solutions I gave work for me.

@zeeg If you find how to prevent this from happening it’s great, so others won’t run in the same trouble. I found the problem thanks to this post http://stackoverflow.com/questions/710586/json-stringify-array-bizarreness-with-prototype-js

I don’t know if delete Array.prototype.toJSON is OK, but as far as I tested, it is : it does not break mootools’ JSON.encode as this series of commands shows:

test = [1,2,3]
[1, 2, 3]
JSON.stringify(test)
""[1,2,3]""
JSON.encode(test)
"[1,2,3]"
delete Array.prototype.toJSON
true
JSON.stringify(test)
"[1,2,3]"
JSON.encode(test)
"[1,2,3]"

@lmeyer @zeeg
Aint sure if u have proceeded with the delete Array.prototype.toJSON. Ive encountered the same problem once while working on the installable js widget. The best solution for this is to delete, do ur thing and restore custom toJSON. Otherwise it can break user code’s assumptions