Page MenuHomePhabricator

Vega outputs console errors on mousemove (!) if the given json contains faulty data
Closed, ResolvedPublic

Description

It seems that Vega has no fallbacks for what happens if a user gives it bad data; instead, it outputs crazy errors to the console (on mousemove over the graph) and loads a blank graph.

We've first seen the error when stack data was inputted with double coordinates by accident. Having no fallback for errors in data, vega "exploded", giving a console error, not rendering the graph in view mode and then outputting more and more errors on mouseover.

Example of faulty data:

  <graph>{
  	"width": 650,
  	"height": 350,
  	"padding": {
		"top": 25,
		"left": 30,
		"bottom": 30,
		"right": 10
  	},
  	"data": [ {
			"name": "table",
			"values": [
				{
					"x": 1,
					"y": 30,
					"c": 0
				},
				{
					"x": 0,
					"y": 55,
					"c": 1
				},
				{
					"x": 1,
					"y": 43,
					"c": 0
				},
				{
					"x": 1,
					"y": 91,
					"c": 1
				},

As you can see, x:1,c:0 exists twice, which makes this a duplicate dataset and hence an error. This isn't a very obvious error, though, so it might be expected to happen especially with direct manipulation of the JSON string.

The errors are -

vega.js:4142 Uncaught TypeError: Cannot read property 'push' of undefined
 
vega.js:2372 Uncaught TypeError: Cannot read property 'marktype' of null (repeatedly, on mouseover)

This means that any user that either makes a mistake or uploads data that has errors may make vega very unhappy and ruin graphs. This is something the Graph extension should validate.

We've submitted a bug upstream to vega about this, and hopefully one day they'll have some sort of 'isValid' method, but as they don't, the data piece of graphs should probably be validated for the user, and the system should refuse to save if the data portion is invalid or has obvious errors.

Event Timeline

Mooeypoo raised the priority of this task from to Needs Triage.
Mooeypoo updated the task description. (Show Details)
Mooeypoo added subscribers: Mooeypoo, ferdbold, Mvolz, Yurik.
Jdforrester-WMF set Security to None.

Make sure to post this bug to https://github.com/uwdata/vega/tree/v2 -- that's where most of their work is being done. Fairly soon we should migrate to that version.

What's most annoying is that is CAN be possible for a graph to be invalid, yet not throw any errors in the console, so it's not like we can use a basic try/catch block to verify if a graph is valid or not :/

BUT! Turns out Vega 2.0 is coming somewhere this summer, and comes with schema validation that will at least take care of validating the guts of a graph spec. However, this mechanism will not prevent errors relative to graph data, such as the one we're having right now. Take some, leave some.

Take a look at the reply I got on GitHub: https://github.com/trifacta/vega/issues/282

It seems version 2.0 will have a schema that helps with validation, but won't have a clear way to actually validate the data given.

Since the graph extension is in production, we might want to make sure the extension itself (and the VE module separately) do at least some basic data validation to prevent these errors. I assume these will have a higher and higher chance of occurrence the more people use graphs in articles.

TheDJ claimed this task.
TheDJ subscribed.

I'm just gonna assume this was resolved when vega2 got deployed. As I've not had Jon report client side logging errors about this yet.