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

Style Dictionary crashes with generic error "Name must be a string" when there is a design token without a name #1102

Open
d49017 opened this issue Feb 8, 2024 · 3 comments

Comments

@d49017
Copy link

d49017 commented Feb 8, 2024

When there is a design token that happens to not have any name, so for example it looks like this { "": { "value": "#", "type": "color" } }, the style dictionary crashes with a really generic error "Name must be a string" which is not helpful at all. I was only able to find this by removing tokens one-by-one.

It would be helpful to know a bit more about the problematic token, like for example where it is (JSONPath or at least line and column), "how it looks like" or what is the exact problem. Would it possible to improve error messages a bit?

node version: 18.14.2
npm version: 9.5.0
style-dictionary version: 3.9.2

@jorenbroekema
Copy link
Collaborator

I think we can improve some of the logs indeed by at least telling the user the filePath of the offending token so it's easier to find. If the token doesn't have a name, it's a bit tricky to tell the user which token has the issue though :\

@d49017
Copy link
Author

d49017 commented May 7, 2024

If the token doesn't have a name, it's a bit tricky to tell the user which token has the issue though :\

That's why I mentioned JSONPath, for example an error may indicate that there is a problem in a child token that is inside the parent accessible under the path a.b.c.d.

@jorenbroekema
Copy link
Collaborator

True, we can use token.path.join('.'), PRs welcome! as of writing, use the v4 branch for now, if that branch no longer exists it means 4.0.0 has been released and the main branch can be used instead.

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

No branches or pull requests

2 participants