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

Improve "unacceptable kind of an object to dump" error message #577

Open
miso-belica opened this issue Sep 18, 2020 · 3 comments
Open

Improve "unacceptable kind of an object to dump" error message #577

miso-belica opened this issue Sep 18, 2020 · 3 comments

Comments

@miso-belica
Copy link

Hello, today I was hunting for a bug during serializing JSON into YAML. I was getting unacceptable kind of an object to dump [object Undefined] but there was no undefined in the JSON. After an hour I was able to find the cause and it was this fragment 1: [null] in the JSON below:

{
	START: {
		CALL: [{ 1: [null], variable: 'utterance' }],
	},
}

The relevant code is at

throw new YAMLException('unacceptable kind of an object to dump ' + type);

The JSON was much bigger and nested that is why it was not easy. But I would like to ask for a better error message so it will be much easier in the future. Would be nice to write the path to the invalid value. For example like this unacceptable kind of an object to dump at path.to.object.START.CALL.0."1".0. Got: ${type}.

I didn't go deeply into the code but if this is possible to get and if you are OK with it I can even try to implement it and send PR.

Thanks for the answer and have a nice day :)

@rlidwka
Copy link
Member

rlidwka commented Dec 18, 2020

I didn't go deeply into the code but if this is possible to get and if you are OK with it I can even try to implement it and send PR.

You can try. Unfortunately, I don't think path to the object is stored anywhere at the moment. Adding it might be a hard task and can run into performance issues.

@ks221197
Copy link

ks221197 commented Jul 8, 2022

@miso-belica did you found solution for this?

@miso-belica
Copy link
Author

@ks221197 yes, the problem is undefined/null somewhere in the JSON. You just have to do inspect(data) before serialising to catch it and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants