launchdarkly / cpp-sdks

C++ Client/Server SDKs
Other
5 stars 2 forks source link

fix: handle omitted evaluation result value when deserializing client-side JSON payload #368

Closed cwaldren-ld closed 5 months ago

cwaldren-ld commented 7 months ago

Background When the client-side SDK is deserializing an evaluation result, it may encounter a null evaluation value for a particular flag. That is, the value is literally null in JSON.

It might also receive an evaliuation result with an omitted value. Some server-side SDKs may produce this because they don't treat null/missing as equivalent.

Problem In that case, the client-side SDK would throw a schema error. This isn't correct since producing a null/omitted value is legitimate.

Solution The deserialization code now takes into account the equivalence of null/omission and doesn't throw an error.

shortcut-integration[bot] commented 7 months ago

This pull request has been linked to Shortcut Story #203949: Treat omitted JSON values as if they were null.

cwaldren-ld commented 6 months ago

Did a more deep audit of the code. I'm seeing an (un-contract-tested) problem in the handling of variations where null evaluation result will result in entering the type-check branch and return a WRONG_TYPE error.

That's not correct. So this PR shouldn't be merged yet until I make some contract tests that cover this (and fix it.)

cwaldren-ld commented 6 months ago

I'm going to merge this as it's a good defensive change in case the SDK is sent bad/malformed data. I've created a ticket to investigate whether a null flag value is possible or not, and if we need to have contract tests to cover this.