Repository navigation
fix: Convert date attributes to ISO-8601 strings in UTC - #34
Open
kinyoklion wants to merge 1 commit into
Open
kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requirements
Related issues
Found during the OpenFeature provider audit against the LaunchDarkly OpenFeature provider spec (OFP context conversion: date/time values must be converted to an ISO-8601 representation in UTC).
Describe the solution you've provided
EvaluationContextConverterpassed custom attribute values toLDContextBuilder::setunchanged. OpenFeature PHP evaluation contexts can carryDateTime/DateTimeImmutablevalues, which the LaunchDarkly context model cannot represent, so date attributes could not be used with thebefore/afteroperators.Custom attribute values are now converted recursively (top level, nested arrays, and individual contexts inside a multi-context):
DateTimeInterfacevalues become UTC ISO-8601 strings with millisecond precision (e.g.2024-03-01T00:30:00.123Z), a format the PHP SDK's date operators parse.null, and arrays keep their current behavior.nulland an error is logged.Describe alternatives you've considered
Formatting as Unix milliseconds. The LaunchDarkly date operators accept both, but the spec calls for ISO-8601 strings, which also keeps the value readable in the LaunchDarkly UI.
Additional context
make checkpasses locally (cs-check, phpstan, phpunit).Link to Devin session: https://app.devin.ai/sessions/b809f0f4a45a48c9a1c079faebb5c70a
Open in Devin Desktop: https://app.devin.ai/desktop/session/b809f0f4a45a48c9a1c079faebb5c70a?variant=devin
Note
Overview
OpenFeature evaluation contexts can include
DateTime/DateTimeImmutableon custom attributes, but those values were passed straight intoLDContextBuilder::set, so they did not work with LaunchDarkly before / after date targeting rules.EvaluationContextConverternow normalizes every custom attribute (including nested arrays and multi-kind sub-contexts) through a newtoLdValuehelper before callingset.DateTimeInterfacevalues are converted to UTC ISO-8601 strings with millisecond precision (e.g.2024-03-01T00:30:00.123Z). Scalars andnullare unchanged. Values that cannot be represented (such as arbitrary objects inside arrays) becomenulland trigger a logged error.Tests cover top-level and nested dates, multi-context dates, and the unconvertible-value path.
Reviewed by Cursor Bugbot for commit fda8ff5. Bugbot is set up for automated code reviews on this repo. Configure here.