Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart.encode() returns confusing error message when using an invalid channel and selections #2175

Closed
dechamps opened this issue May 25, 2020 · 1 comment · Fixed by #2842
Closed

Comments

@dechamps
Copy link

dechamps commented May 25, 2020

Consider:

selection = alt.selection_single()
(alt.Chart(data=None)
    .mark_circle()
    .encode(color=alt.value('red'), invalidChannel=None))

Predictably, this fails with:

SchemaValidationError: Invalid specification
        altair.vegalite.v4.schema.core.FacetedEncoding, validating 'additionalProperties'
        Additional properties are not allowed ('invalidChannel' was unexpected)

So far so good. But now watch what happens if x is set to a selection:

selection = alt.selection_single()
(alt.Chart(data=None)
    .mark_circle()
    .add_selection(selection)
    .encode(
        color=alt.condition(selection, alt.value('red'), alt.value('green')),
        invalidChannel=None))

This time, the error message is way more confusing and doesn't point to the actual cause of the problem:

SchemaValidationError: Invalid specification
        altair.vegalite.v4.schema.channels.ColorValue, validating 'additionalProperties'
        Additional properties are not allowed ('selection' was unexpected)

The misleading error message made me waste a lot of time chasing down dead ends simply because I mistyped tooltip as tooltips :(

@jakevdp
Copy link
Collaborator

jakevdp commented May 25, 2020

Yes, this is pretty misleading. It’s difficult to specialize, because validation errors come from validating the schema of the full chart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants