Error message names the wrong class or parameter in some unions and channels
Two cases where the error message names the wrong class. Found while reviewing #4137, out of scope there.
1. A clash inside condition is blamed on the channel.
alt.Chart("d.csv").mark_point().encode(
color={"condition": {"test": "x", "param": "p", "value": "r"}, "value": "b"}
).to_dict()SchemaValidationError: `ColorValue` does not accept 'param', 'test' and 'value' together See the help for `ColorValue` to read the full description of these parameters
ColorValue does accept value, so the sentence reads as wrong. The real problem is that test and param cannot go together inside condition. There are also no "belongs to" lines, because the forms of the condition have no public class (ConditionalParameter<...>, ConditionalPredicate<...>).
Better would be to name the condition and point at test and param.
2. A tooltip in a list is named after the schema, not after the class the user wrote.
alt.Chart("d.csv").mark_point().encode(tooltip=[alt.Tooltip("a:N", bogus=1)]).to_dict()SchemaValidationError: `StringFieldDef` has no parameter named 'bogus' Existing parameter names are: aggregate field timeUnit bandPosition format title bin formatType type See the help for `StringFieldDef` to read the full description of these parameters
The user wrote alt.Tooltip, not StringFieldDef. Without the list it says Tooltip:
alt.Chart("d.csv").mark_point().encode(tooltip=alt.Tooltip("a:N", bogus=1)).to_dict()SchemaValidationError: `Tooltip` has no parameter named 'bogus' Existing parameter names are: shorthand bin format title aggregate condition formatType type bandPosition field timeUnit
The table under StringFieldDef is the more precise one: an item in a tooltip list has no condition. So ideally the message says Tooltip and shows the names that are valid for an item in the list.
3. value together with datum names one of the two.
alt.Chart("d.csv").mark_point().encode(y=alt.Y(value=1, datum=2)).to_dict()SchemaValidationError: `YDatum` does not accept 'datum' and 'value' together 'datum' belongs to `PositionDatumDef` 'value' belongs to `PositionValueDef` See the help for `YDatum` to read the full description of these parameters
"YDatum does not accept 'datum'" reads as wrong. Y would fit better here. The "belongs to" lines also use the schema names. The user knows these as YDatum and YValue, not PositionDatumDef and PositionValueDef.
4. A shorthand is reported as field.
alt.Chart("d.csv").mark_point().encode(y=alt.Y("a:Q", datum=1)).to_dict()SchemaValidationError: `YDatum` has no parameter named 'field' Existing parameter names are: datum impute title axis scale type bandPosition stack
The user wrote the shorthand "a:Q", not field. The shorthand is expanded into field and type before validation, so the message names what it was expanded into. Mentioning the shorthand would make it easier to find.
Source: vega/altair