(FFM-4463) Update parser validation #39
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Tylertech experienced an issue using the .NET sdk with ff-proxy where if they had a target group with no rules configured the .NET sdk would fail to parse the target groups from the http response during initialisation and error out.
We also previously had this issue from Sharp Gaming if the feature variationToTargetMap was empty.
After digging into this issue I noticed that both of these problem fields were the only properties in our generated spec annotated with
AllowNull
instead ofDisallowNull
. The behaviour of these two properties are described here:AllowNull: The property must be defined in JSON but can be a null value.
DisallowNull: The property is not required but it cannot be a null value.
Hence the reason it failed to parse was because the proxy didn't send these properties if they didn't exist (which is the correct behaviour)
Default: The property is not required. The default state.
Solution
My plan was to install nswag and play around with the code generation properties until I could get these two fields to also generate as
DisallowNull
fields.However after just running nswag with the current config I noticed it auto changed them to
DisallowNull
fields anyway, so they must have been manually edited when these generated files were first committed.After changing them to
DisallowNull
though I realised that the build tests were failing because they contain a null variationToTargetMap here (I assume this is why it was manually changed in the first place so these tests could pass)The less than ideal (but better than what we have now) solution I've gone for is to change these fields to have the property
Default
which allows the fields to be either null or missing. Ideally all fields in this generated spec should be like this but after searching github discussions there doesn't seem to be any easy way to do it bar manually changing the generated code.Testing
Tested against ff-proxy and it solves the issue the customer was seeing
Tested against saas and behaviour is still correct
Longer term
We should have a way to generate the annotations (or lack of) that satisfies the needs of the sdk and also the test cases, from looking through the spec it appears there were a few other manual edits that stray from the originally generated code, this could cause problems if we ever need to rev this spec