Skip to content

fix: Convert date attributes to ISO-8601 strings in UTC - #34

Open
kinyoklion wants to merge 1 commit into
mainfrom
devin/1793922210-php-date-attributes
Open

kinyoklion wants to merge 1 commit into
mainfrom
devin/1793922210-php-date-attributes

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions (local run on PHP 8.5; CI covers 8.2–8.4)

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

EvaluationContextConverter passed custom attribute values to LDContextBuilder::set unchanged. OpenFeature PHP evaluation contexts can carry DateTime/DateTimeImmutable values, which the LaunchDarkly context model cannot represent, so date attributes could not be used with the before/after operators.

Custom attribute values are now converted recursively (top level, nested arrays, and individual contexts inside a multi-context):

  • DateTimeInterface values 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.
  • Scalars, null, and arrays keep their current behavior.
  • Any other value (for example, an arbitrary object nested in an array) becomes null and 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 check passes 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 / DateTimeImmutable on custom attributes, but those values were passed straight into LDContextBuilder::set, so they did not work with LaunchDarkly before / after date targeting rules.

EvaluationContextConverter now normalizes every custom attribute (including nested arrays and multi-kind sub-contexts) through a new toLdValue helper before calling set. DateTimeInterface values are converted to UTC ISO-8601 strings with millisecond precision (e.g. 2024-03-01T00:30:00.123Z). Scalars and null are unchanged. Values that cannot be represented (such as arbitrary objects inside arrays) become null and 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.

Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 5, 2026 23:44
@devin-ai-integration
devin-ai-integration Bot requested a review from a team as a code owner November 5, 2026 23:44
@devin-ai-integration
devin-ai-integration Bot marked this pull request as draft November 5, 2026 23:44
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 5, 2026 23:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant