-
Notifications
You must be signed in to change notification settings - Fork 0
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
TOML file: crash when given keyword misses quotes #313
Comments
This is arguably a failure of the TOML parser; it could give a more meaningful error. But that's an upstream issue. One possible solution is catching this error and wrapping it. I'm not sure that a very sustainable solution: we use TOML everywhere, and I don't think we would want error wrapping everywhere. To be fair, the "invalid value" error is not that bad; the phrasing is too terse, and ideally it should mention the key, maybe mention that types matter, and not just the line number. It's just that people will see a configuration file, think "I get it", not read any specification and then get unpleasantly surprised when they got something as simple as a config file wrong. |
For comparison, the JSON parser doesn't give a lot more info either. JSON keys need to be quoted too, error's okay: In [11]: json.loads('{stuff: stuff}')
JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) But if you screw up the value: json.loads('{"stuff": stuff}')
JSONDecodeError: Expecting value: line 1 column 11 (char 10) It's pretty much the tomllib error. |
@FransRoelofsen, how did you make the TOML file? As @HendrikKok mentioned, most of the time the TOML file will be generated by Python as well. |
The TOML file contains several keywords, for instance "dll". These keywords expect a reference to a file. In case such a fille name doesn't contain spaces, users might give an unquoted line, like dll = \path\to\MetaSWAP.dll
However, this causes a crash and a message "Invalid value (at line 10, column 7)."
I found out that the TOML must contain a "python linke" string, so always including quotes. That is not clear for a user.
Suggestion: build in a check for a string value and if not present, please close the program with a clear message about this string requirement.
The text was updated successfully, but these errors were encountered: