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

Dynamic.dict decoder needs more informative errors #740

Open
sporto opened this issue Nov 16, 2024 · 3 comments
Open

Dynamic.dict decoder needs more informative errors #740

sporto opened this issue Nov 16, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sporto
Copy link
Contributor

sporto commented Nov 16, 2024

When a value fails to decode when using dynamic.dict, we get an error that says values.

e.g.

Error(DecodeError(expected: "another type", found: "Object", path: ["values"]))

If you have dozens of values to decode, this doesn't give any information about which value failed.
CrowdHailer/oas#1

I would like to modify this decoder to return the name of the key.

@lpil
Copy link
Member

lpil commented Nov 17, 2024

Sounds good!

@lpil lpil added good first issue Good for newcomers help wanted Extra attention is needed labels Nov 17, 2024
@sporto
Copy link
Contributor Author

sporto commented Nov 17, 2024

In #741 I tried to add more information by adding an index like values[2]. But that doesn't work well.

The name of the key is available, but only if the key decoder is for a string.
Otherwise the key can be anything. Don't know what could be a good strategy for this.
We could use string.inspect perhaps.

@lpil
Copy link
Member

lpil commented Nov 19, 2024

The module already defines logic for turning any value into a string for use in the error path, we'd use that again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants