mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Support better error hints when importing data from Parser sources
#79
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Senjai on GitHub (Feb 19, 2024).
Philliam and I were discussing JSON error reporting in Discord.
Currently, there is no
pkl importtype command I am aware of that allows us to import JSON/YAML/etc into PKL, so I am making the assumption the only way to bring in external data is through the Parser subclasses.For this example we'll use JSON.
Consider the following
intro.json
{ "hello": "world", "test": "oops" }The error I see here is:
While this offers a value hint that I can then grep
intro.jsonfor to find, if you have a sufficiently large JSON file this becomes challenging to rely on for debugging purposes.Some other configuration languages, such as cue have errors that can look like this:
While this error message isn't fantastic either, it does identify that the problem is with the 5th vertical, and 768th attribute, which gives much higher signal on how to go about dealing with the error.
I'd love to see either the parser be smarter about reporting on errors in this fashion, even if it dynamically just references the path of the data that's problematic, or if there's a way we can
pkl importnon pkl files, as an analogue topkl eval -f formatso that we can get native PKL error reporting on these issues.