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

Fix default serialization #664

Merged
merged 10 commits into from
Jun 12, 2024
Merged

Fix default serialization #664

merged 10 commits into from
Jun 12, 2024

Conversation

vsmalladi
Copy link
Contributor

@vsmalladi vsmalladi commented Apr 5, 2024

Closes #659

@BMurri BMurri requested review from BMurri and MattMcL4475 April 5, 2024 20:44
@BMurri BMurri changed the title Fix default serialization. Closes #659 Fix default serialization Apr 5, 2024
@MattMcL4475
Copy link
Collaborator

MattMcL4475 commented Apr 5, 2024

The current change looks like it will just not serialize default properties... but won't resolve #659

Seems like to resolve #659 something like this is needed:

opts.SerializerSettings.Converters.Add(new StringEnumConverter());

This also needs a unit test.

@BMurri
Copy link
Collaborator

BMurri commented Apr 6, 2024

The current change looks like it will just not serialize default properties... but won't resolve #659

The 0 is the default value of the TesFileType enumeration, which value does not actually exist (look at the code). That zero was written by the StringEnumConverter. Adding another one won't do anything (one was already added by the attribute in that code file).

I agree with unit tests, though.

@MattMcL4475

@vsmalladi
Copy link
Contributor Author

vsmalladi commented Apr 6, 2024

@BMurri should the default be 1 then if not provided or null since it is not required on until runtime from the server to update FileType

…ft/ga4gh-tes into vsmalladi/SerializerSettings-659
@BMurri
Copy link
Collaborator

BMurri commented Apr 7, 2024

My understanding is that the server is expected to only provide missing types on outputs, per the discussions associated with the removal of the requirement to provide type when submitting the task to the server (a change in 1.1), but maybe I'm recalling that discussion incorrectly. Note also that determination of type when it's missing can only be done with certain kinds of source storage locations, e.g. generic web URLs is one case where directory inputs are not possible to implement.

If the default is changed to 1, then there'll be no way for the server to know it wasn't set in the first place. Making it nullable would be a possibility, but with the proposed fix the entire property will not be written in the JSON when clients retrieve the task when its value is the default (of 0) (along with all other properties that are missing values). Note that arrays that are present but empty will be written with this fix (to prevent writing them would require them to be null).

@vsmalladi
Copy link
Contributor Author

I think if its not provided it should be null.

@BMurri
Copy link
Collaborator

BMurri commented Apr 15, 2024

I think if it's not provided it should be null.

In C# it's an enumeration. Our choices are:

  1. if it's not provided it's completely missing when retrieving the task and its value is 0 when accessing it inside of the server
  2. We explicitly make it a Nullable<>

1. is what the current state of this fix does.

@vsmalladi
Copy link
Contributor Author

I think if it's not provided it should be null.

In C# it's an enumeration. Our choices are:

  1. if it's not provided it's completely missing when retrieving the task and its value is 0 when accessing it inside of the server
  2. We explicitly make it a Nullable<>

1. is what the current state of this fix does.

So the JSON resturned would be still 0 or null from the API

@BMurri
Copy link
Collaborator

BMurri commented Apr 16, 2024

So the JSON resturned would be still 0 or null from the API

In the JSON it is entirely missing. In the POCO model, it is 0.

@vsmalladi
Copy link
Contributor Author

In the JSON it is entirely missing. In the POCO model, it is 0.

That seems reasonable to me.

@vsmalladi vsmalladi merged commit 5fa4113 into main Jun 12, 2024
7 checks passed
@vsmalladi vsmalladi deleted the vsmalladi/SerializerSettings-659 branch June 12, 2024 20:53
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

Successfully merging this pull request may close these issues.

TES file type enum is wrong
3 participants