-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
Better message when failing to match any variant of an untagged enum #773
Comments
Closing as more complicated than it's worth. I would be willing to consider a PR that implements better error messages but I don't plan to pursue this as a priority. |
This also adds a verbose-debug feature that enables the new behavior. Previously: > data did not match any variant of untagged enum ReferenceOr at line 6 column 4 Now, with `verbose-debug` feature enabled: > data did not match any variant of untagged enum `ReferenceOr` > - attempted to deserialize `Reference` but failed with: missing field `$ref` > - attempted to deserialize `Item` but failed with: invalid value: string "lol", expected expected format `\dXX` at line 6 column 4 cf. serde-rs#773
I don't have a PR but I'd like to add my experience with this error in case someone want to pick this up. I've hit this error as a consumer (not developer) of the vector logging binary. The error is confusing because I'm not sure what went wrong. Specifically, here was the rough mental debugging I went through:
|
This also adds a verbose-debug feature that enables the new behavior. Previously: > data did not match any variant of untagged enum ReferenceOr at line 6 column 4 Now, with `verbose-debug` feature enabled: > data did not match any variant of untagged enum `ReferenceOr` > - attempted to deserialize `Reference` but failed with: missing field `$ref` > - attempted to deserialize `Item` but failed with: invalid value: string "lol", expected expected format `\dXX` at line 6 column 4 cf. serde-rs#773
In polkadot: ---- call_function_actually_work stdout ---- thread 'call_function_actually_work' panicked at 'called `Result::unwrap()` on an `Err` value: RpcTransactionError { code: -32700, message: "Parse error", data: None }', node/test/service/tests/call-function.rs:29:60 Issues related: serde-rs/json#559 serde-rs/serde#773
@jschaf sounds like i'm hitting the exact error you are (even down to |
Sorry, I've forgotten most of the context. It might have been mismatch between the docs which show version 2 rules, and the vector implementation at the time which defaulted to version 1. I remember diving through the vector source code to figure out what version 1 expected. If it helps, here's my current working invocation of that transform: # Transform to extract whitelisted fields from the JournalD src.
[transforms.journald_src]
type = "lua"
version = "2"
inputs = ["journald_raw_src"]
search_dirs = ["/etc/vector/lua"]
source = "journald = require('journald')"
hooks.process = 'journald.extract_whitelisted_fields' |
To eventually save someone's time.
Should be:
|
serde and serde_yaml generate terrible error messages for untagged enums. We can fix this with manual deserialization. Or at least improve it. serde-rs/serde#773 serde-rs/serde#741 dtolnay/serde-yaml#201
This message could be a lot better.
https://github.com/serde-rs/serde/blob/v0.9.7/serde_derive/src/de.rs#L750-L756
The text was updated successfully, but these errors were encountered: