Open mojodna opened 9 years ago
The problem is how carto build the error messages: https://github.com/CartoDB/carto/blob/master/lib/carto/parser.js#L243-L250
What would work better for you? Having an array of error messages? Having an per layer array with errors per layer?
About the Map in style1 (layer 1) that's because we apply Map rules for all layers instead of per layer :disappointed:.
I guess you are getting those errors at named map instantiation, right? Named map template should be validated on creation/update time so we could avoid a lot of errors in run time: https://github.com/CartoDB/Windshaft-cartodb/issues/134
This is kind of similar to https://github.com/CartoDB/Windshaft-cartodb/issues/84
I added a test with a simplified version of the map configuration: https://github.com/CartoDB/Windshaft/commit/f789e642f89e0ef3c372a53536cce140cc64d396
I've seen boilerplate like this, originally from https://github.com/mapbox/carto#from-code. Not sure how that plays into things.
if (Array.isArray(err)) {
err.forEach(function(e) {
carto.writeError(e, options);
});
What would work better for you? Having an array of error messages? Having an per layer array with errors per layer?
Probably array of messages (parsed, with the location separate from the message) per layer, keyed by layer name.
I guess you are getting those errors at named map instantiation, right? Named map template should be validated on creation/update time so we could avoid a lot of errors in run time: #134
Yup, but I'm working around it by immediately instantiated a map. It'd be nice to eliminate that. It'd also be nice to be able to not have to check for the existence of a named map before deciding whether to POST
or PUT
(with the name, which is also in the payload). Not sure what makes the most sense there though...
The following named map configuration (which should work against any account since it doesn't reference any tables) triggers the below error, which a) requires excessive parsing and b) includes error messages referencing line numbers that don't exist.
(Yes,
bufferz-size
is an intentional typo.)Excessive parsing: splitting the newlines for each item in
errors
, stripping theError:
prefix, determining which layer corresponds tostyleN
(it's not as simple as treatingN
as the layer index, as layers without CartoCSS don't increase the style count).style0:8:2 Unrecognized rule: bufferz-size. Did you mean buffer-size?
is correct.I'm not sure what's triggering
style1:4:56 Rule bufferz-size not allowed for Map
; it doesn't correspond to anything in the map config. Given the column index (56), I suspect that a flattened (newlines stripped) version of the first stylesheet is being appended to the second (but why is the error message different?). (This is further supported by seeing repeated errors from maps with many more layers; to parse them, I took each line from each error item and pulled the unique values out.)