Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix use of deserializer_opts in file.serialize #52526
What does this PR do?
Corrects code attempting to pull deserialize_opts using the serializer_name instead of deserializer_name
What issues does this PR fix or reference?
deserializer_opts are packed into the deserializer_options dict using the deserialzier_name as the key. However, when retrieved to pass to the deserializer, the serializer_name is used.
deserializer_name is used to retrieve the options
Commits signed with GPG?
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.
dwoz left a comment
@lomeroe It looks like we're removing coverage from the json formatter in your test change. I'm concerned that we'll now catch a bug when using the configparser formatter but miss a bug when using the json formatter. Maybe it's better to make a new test for configparser?
@dwoz the purpose of that test seemed to only be to validate that the serializer_opts and deserializer_opts being passed in the state were functioning correctly (and being used), which it was not doing. My opinion was that the particular formatter did not make a difference for the test case. Configparser is the easiest to assert, from a data perspective, that the serializer/deserializer options are in effect. For the json formatter, there are no options that can be passed (as a string) to modify the returned data (parameters that can must be passed in as functions) to validate the option's functionality. The json test could be kept, but modified to pass an encoding such as utf-16 or utf-32 which will raise an error and that could be asserted. As it was, passing an encoding of latin-1 is no different than the default, and can't be validated that it was actually passed to the deserializer function (which is why the test wasn't catching that the options weren't even being passed).
In my opinion, I don't see that it gains anything to test options to both formatters, but at the same time have no issue putting the test in there if you want it.