You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ux: Lack of key and origin in ConfigError::Message leads to uncertain sources from serde error messages #532
If a configuration error passes through a serde::de::Error implementation, it is wrapped as a ConfigError::Message, and information about what caused the error is not preserved. This confuses the users, because the message does not tell them which option was set incorrectly.
If the above code is run with the configuration direct = "foo", then we get a helpful error message: invalid type: string "foo", expected an integer for key `direct` in demo.toml
But if the above code is run with the configuration via_serde = "foo", then we get the not-so-helpful message: invalid digit found in string.
Note that it doesn't mention "via_serde" or "demo.toml".
It would be great if instead we go something like: invalid digit found in string (for key `via_serde` in demo.toml
Possible solutions
My first thought here would be to adjust Message to include an optional key fields, so that prepend_key can set it.
If we don't want to break backward compatibility with code that uses the current Message variant, I would define a new MessageWithKey or InvalidValue error variant, and have prepend_key() convert Message into that variant instead.
Activity
feat: Improve errors from try_deserialize
feat: Improve errors from try_deserialize
epage commentedon Sep 30, 2025
#695 originally covered several cases but pulled back due to some of them requiring a breaking change.
feat: Improve errors from try_deserialize (#695)