Skip to content

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

Closed

Description

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 :(

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions