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

Somewhat unhelpful error message when passing a string that does not correspond to a column name #3521

Open
joelostblom opened this issue Aug 4, 2024 · 0 comments
Labels

Comments

@joelostblom
Copy link
Contributor

What happened?

If I pass a byte string to sort like so:

alt.Chart(pd.DataFrame({'col1': ['c', 'a', 'b']})).mark_point().encode(alt.X('col1').sort(b'cba'))

I'm getting an error messages that says

SchemaValidationError: 'b'cba'' is an invalid value for `sort`. Valid values are:

- One of ['ascending', 'descending']
- One of ['x', 'y', 'color', 'fill', 'stroke', 'strokeWidth', 'size', 'shape', 'fillOpacity', 'strokeOpacity', 'opacity', 'text']
- One of ['-x', '-y', '-color', '-fill', '-stroke', '-strokeWidth', '-size', '-shape', '-fillOpacity', '-strokeOpacity', '-opacity', '-text']
- Of type 'array', 'string', 'object', or 'null'

Notice how the last line mentions that a string can be passed. However, if I do pass a string (that is not an existing column name), that last line of the error message changes to:

- Of type 'array', 'object', or 'null'

I noticed this when reviewing #3501. I'm not sure how important this is and I don't think we should spend a whole lot of time on it, but it is somewhat unhelpful that it is indicated that strings cannot be passed whereas they actually can as long as they correspond to a column/field name. Ultimately we would want a more informative and correct error message, but this is pretty low priority.

What would you like to happen instead?

No response

Which version of Altair are you using?

main

@joelostblom joelostblom added the bug label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant