-
Notifications
You must be signed in to change notification settings - Fork 13
Serialiser_Engine: Added condition that the serialised value must be null if the deserialised result was null. #3463
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
base: develop
Are you sure you want to change the base?
Conversation
…he original value was not null
@BHoMBot check versioning |
@Tom-Kingstone to confirm, the following actions are now queued:
There are 2 requests in the queue ahead of you. |
@BHoMBot check unit-tests |
@Tom-Kingstone to confirm, the following actions are now queued:
|
To comment on this as well as I was part of the investigation and finding the solution. By pure principle, I think this change is correct as getting a null back should in principle only be ok if the serialised. Need to investigate if this causes any fallout for various cases and seems like you have already found one case @Tom-Kingstone . That to me highlights that we need to be quite stringent and really check this through as full as possible. Given the failing UT-s are mine, I can look into them. |
@IsakNaslundBh { "_t" : "System.Type", "Name" : "" } Which when run through full json of the object so you can test yourself: {
"_t" : "BH.oM.Matter.Options.DensityExtractionOptions",
"Type" : { "_t" : "System.Type", "Name" : "" },
"AllowFallbackIfNoType" : false,
"ExtractionType" : "AllMatching",
"EqualTolerance" : 0.001,
"IgnoreZeroValues" : false,
"ZeroTolerance" : 9.9999999999999995E-07
}
|
Thanks Tom. Looking into that json, it looks... wrong to me. Name should always be set in the Type. A null type should just be BsonNull, not set as a type with no name. That said, need to understand the scope of this, if this is just a annoyance in these unit-tests, or if it is a propagating problem for many cases that has Type as a property... |
Did a bit of digging, and the problem with the types is coming from our old serialiser:
The comment there about why it was done this way might be a good indication that this should be the only place bson nulls are skipped though, so one can at least hope that this is the only edgecase. So, one solution to this might be to add a IsValidNull method accepting a BsonValue, were we can add this and any other edgecases we might find. Hope not to many of them though, but think we at least need to check through the old serialiser to check how things like methods etc are handled in there. From my initial checking though, I cant find any other place where nulls are checked for, and dealt with in another way then simply BHoM_Engine/Serialiser_Engine/Objects/BsonSerializers/MethodBaseSerializer.cs Lines 52 to 59 in 43ee03d
Hence, a method, something like:
Might be a start - to be expanded upon if need be! Another option for this is to try to add versioning for this case, turning type documents of that format into nulls. Might be worth exploring as well. |
@Tom-Kingstone had a brief chat with @adecler about this, and think this might require a bit of a zoomout before we just patch with the current PR. If ok with you, will try to tackle this next sprint, making sure we set it up in a way that hopefully covers even more cases. |
added parked status awaiting end of testing sprint |
NOTE: Depends on
Issues addressed by this PR
Closes #3462
See the linked issue:
With help from @IsakNaslundBh in isolating the problem, added a condition to
CanSetValueToProperty
which ensures that if a deserialised property is null, then the serialised property must also have been null to pass.Test files
See the linked issue for a script that demonstrated the original problem - There is still an error being recorded (as a value is still being deserialised to null) but the versioning upgrade is happening and the object contains the FileSettings object in a correct form (rather than null/empty)
There will be knock-on effects from this PR on historical versioning, which will likely snowball so testing for this will be ongoing. Running versioning will probably highlight some of these but as @IsakNaslundBh says, much will be missed and it is best to test thoroughly
Changelog
Additional comments