Skip to content

Thread FlagDetails.metadata into ProviderEvaluation flagMetadata#23

Open
typotter wants to merge 5 commits into
mainfrom
typo/thread-flag-details-metadata-to-openfeature
Open

Thread FlagDetails.metadata into ProviderEvaluation flagMetadata#23
typotter wants to merge 5 commits into
mainfrom
typo/thread-flag-details-metadata-to-openfeature

Conversation

@typotter

@typotter typotter commented Jun 11, 2026

Copy link
Copy Markdown

What and why?

FFL-2510 — ProviderEvaluation+DatadogFlags.swift was passing flagMetadata: [:] for all flag types, discarding the metadata field on FlagDetails (which carries allocationKey and extraLogging primitives from the Precomputed Flags response).

How?

  • Added toOpenFeatureFlagMetadata() private extension on [String: AnyValue] that converts each AnyValue case (.string, .int, .double, .bool) to the corresponding FlagMetadataValue via FlagMetadataValue.of(). Complex types (.dictionary, .array, .null) are dropped — not representable as FlagMetadataValue.
  • All 5 ProviderEvaluation extensions now pass details.metadata.toOpenFeatureFlagMetadata() instead of [:]
  • Tests: ProviderEvaluationMetadataTests covering String/Int/Double/Bool metadata propagation and empty-metadata pass-through (44/44 pass)

Dependencies and merge order

Depends on: DataDog/dd-sdk-ios#2989 (adds FlagDetails.metadata)

Package.swift currently pins dd-sdk-ios to branch typo/thread-allocation-key-to-flag-details-metadata so this PR can be reviewed. Before merging, update the pin to the released version tag once dd-sdk-ios #2989 merges and a release is cut. The Package.resolved must also be updated at that time.

Verification

CI: Platform Tests (iOS/macOS/tvOS) ✓, Unit Tests ✓, Lint ✓. Smoke Tests (iOS) fails because the smoke test project resolves dd-sdk-ios from GitHub and the feature branch isn't in its resolution path — this is a known branch-pin artifact that resolves when dd-sdk-ios #2989 merges.

typotter added 2 commits June 11, 2026 11:22
- Add toOpenFeatureFlagMetadata() helper on [String: Any] that converts
  to [String: FlagMetadataValue], widening Swift Int to Int64 for
  FlagMetadataValue.of() compatibility
- Replace flagMetadata: [:] with details.metadata.toOpenFeatureFlagMetadata()
  in all five ProviderEvaluation extensions
- Point Package.swift at local dd-sdk-ios path to pick up metadata field
- Add ProviderEvaluationMetadataTests covering populated and empty metadata
Uses branch reference while dd-sdk-ios PR #2989 is in review.
Update to a version tag once that PR merges and a release is cut.
@typotter typotter requested a review from a team as a code owner June 11, 2026 17:26
@typotter typotter requested review from dd-oleksii and greghuels and removed request for a team June 11, 2026 17:26
@dd-octo-sts-150931

Copy link
Copy Markdown

🐑 PR Shepherd is maintaining this PR

I watch your PR and automatically fix CI failures, rebase your branch, handle flaky tests, and push it to the merge queue when it's ready.

More about what I do → Guide

To pause me on this PR, add the flow-skip label.

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 11, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/dd-openfeature-provider-swift | Smoke Tests (iOS)   View in Datadog   GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 841d6b2 | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f237aef946

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Package.swift
dependencies: [
.package(url: "https://github.com/open-feature/swift-sdk.git", "0.3.0"..<"0.4.0"),
.package(url: "https://github.com/DataDog/dd-sdk-ios.git", from: "3.2.0"),
.package(url: "https://github.com/DataDog/dd-sdk-ios.git", branch: "typo/thread-allocation-key-to-flag-details-metadata"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a released dd-sdk-ios dependency before publishing

This branch: dependency makes any tagged release of this provider unusable for normal SPM consumers: SwiftPM rejects packages with branch-based transitive dependencies when the root package depends on them by version (the documented install path is .upToNextMajor(from: "0.1.0")). In that scenario the resolver fails before building, so this metadata change should wait for a released dd-sdk-ios version (and matching CocoaPods constraint) instead of pinning the provider manifest to a feature branch.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remember to change this back before merging

@typotter

Copy link
Copy Markdown
Author

Depends on: DataDog/dd-sdk-ios#2989 — adds FlagDetails.metadata with allocationKey and extraLogging primitives that this PR threads into ProviderEvaluation.flagMetadata. The Package.swift pin should be updated to a version tag once that PR merges and a release is cut.

@typotter

Copy link
Copy Markdown
Author

FFL-2510

Comment thread Package.swift
platforms: [
.iOS(.v14),
.macOS(.v12),
.macOS("12.6"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this version bump related to the metadata change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latest dd-sdk-ios package.swift has bumped to 12.6 so too must we here

Comment thread Package.swift
dependencies: [
.package(url: "https://github.com/open-feature/swift-sdk.git", "0.3.0"..<"0.4.0"),
.package(url: "https://github.com/DataDog/dd-sdk-ios.git", from: "3.2.0"),
.package(url: "https://github.com/DataDog/dd-sdk-ios.git", branch: "typo/thread-allocation-key-to-flag-details-metadata"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remember to change this back before merging

value: true,
variant: "on",
reason: "targeting_match",
metadata: ["allocationKey": .string("alloc-abc"), "version": .string("2")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add a few more types in here for more test coverage: int, double, bool, etc

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// MARK: - Private Helpers

private extension [String: AnyValue] {
/// Converts an AnyValue metadata dictionary to the OpenFeature FlagMetadataValue map.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks like you were already expecting AnyValue on this end

- Add intMetadataThreadedIntoFlagMetadata test for .int -> FlagMetadataValue.integer
- Add doubleMetadataThreadedIntoFlagMetadata test for .double -> FlagMetadataValue.double
- Add boolMetadataThreadedIntoFlagMetadata test for .bool -> FlagMetadataValue.boolean
@typotter typotter force-pushed the typo/thread-flag-details-metadata-to-openfeature branch from 87a80bc to 841d6b2 Compare June 12, 2026 04:12
@typotter typotter requested a review from sameerank June 12, 2026 21:11

@sameerank sameerank left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the smoke test depends on DataDog/dd-sdk-ios#2989 so you might have to wait a little before this CI passes and can be merged

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants