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

Error for mandatory fields #87

Open
akguin opened this issue Oct 28, 2022 · 3 comments
Open

Error for mandatory fields #87

akguin opened this issue Oct 28, 2022 · 3 comments
Labels
bug Something isn't working V4 candidate Candidate for next major release

Comments

@akguin
Copy link

akguin commented Oct 28, 2022

Not providing a mandatory field, its not throwing error.

@AdrianStrugala
Copy link
Owner

Hello,

Thank you for creating the issue. Could you please add more details that could help me in the investigation? Preferably schema and sample data.

Regards,
Adrian

@akguin
Copy link
Author

akguin commented Oct 28, 2022

Hello Adrian,
Below is the details...
string jsonString = "{"name": "Ram", "favorite_number": 7, "favorite_color": "green"}";
var schemaJson = "{"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["null","int"]},{"name":"favorite_color","type":["null","string"]}]}";

And My code to serialize:
var jsonObject = JsonConvert.DeserializeObject(jsonString);
return AvroConvert.SerializeHeadless(jsonObject, schemaJson);

If you see name is a mandatory field in schema but we are not sending it in jsonString, but it is able to serialize without any error.

Also can we convert it with jObject inseat of generic T object.

@AdrianStrugala
Copy link
Owner

AdrianStrugala commented Oct 28, 2022

Hi,

Thank you for the details. Your suggestion is right according to the Avro specification and I will investigate implementation options.

Since this is a breaking change, I am tagging this issue as a V4 request.

Thanks,
Adrian

@AdrianStrugala AdrianStrugala added issue This doesn't seem right V4 candidate Candidate for next major release labels Oct 28, 2022
@AdrianStrugala AdrianStrugala added bug Something isn't working and removed issue This doesn't seem right labels Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working V4 candidate Candidate for next major release
Projects
None yet
Development

No branches or pull requests

2 participants