Add metadata field to FlagDetails and populate allocationKey#2989
Add metadata field to FlagDetails and populate allocationKey#2989typotter wants to merge 11 commits into
Conversation
🐑 PR Shepherd is maintaining this PRI 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fab5658b5
ℹ️ 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".
…etadata - Add `extraLogging: [String: AnyValue]` property to `FlagAssignment` with default `[:]` - Add `extraLogging` CodingKey and decode with `decodeIfPresent` for backwards compatibility - Encode `extraLogging` in `encode(to:)` - In `FlagsClient.getDetails`, merge `extraLogging` primitive values (string, int, double, bool) into metadata before writing `allocationKey`; skip any `allocationKey` key in extraLogging so the typed field always wins - Update `testGetDetails_includesAllocationKeyInMetadata` to assert extraLogging values appear in metadata - Add `testGetDetails_extraLoggingAllocationKeyDoesNotOverrideTypedAllocationKey` - Update `testDecoding` expected values to include `extraLogging: ["experiment": .bool(true)]` - Add `testDecodingFlagAssignmentWithExtraLogging` and `testDecodingFlagAssignmentWithoutExtraLogging`
This comment has been minimized.
This comment has been minimized.
…rror-path metadata tests - Remove try? from decodeIfPresent so malformed extraLogging payloads surface decode errors - Skip encoding extraLogging when empty to match round-trip symmetry with decodeIfPresent - Rename loop variable key to logKey in getDetails to avoid shadowing outer key parameter - Add testGetDetails_errorPathsHaveEmptyMetadata verifying metadata is empty on all three error paths
|
Required by: DataDog/dd-openfeature-provider-swift#23 — the Swift OpenFeature provider depends on |
- Change metadata type from [String: Any] to [String: AnyValue] - Remove custom == operator; synthesized Equatable now handles [String: AnyValue] - Remove import Foundation from FlagDetails.swift (no longer needed) - Update getDetails to assign AnyValue directly instead of switch-casting - Update tests to use AnyValue enum cases instead of as? casts - Regenerate api-surface-swift to reflect new metadata field type
|
FFL-2510 |
sameerank
left a comment
There was a problem hiding this comment.
I think you may also need to add an entry to the "Unreleased" section of CHANGELOG.md
| public var doLog: Bool | ||
| public init(allocationKey: String, variationKey: String, variation: Variation, reason: String, doLog: Bool) | ||
| public var extraLogging: [String: AnyValue] | ||
| public init(allocationKey: String,variationKey: String,variation: Variation,reason: String,doLog: Bool,extraLogging: [String: AnyValue] = [:]) |
There was a problem hiding this comment.
There used to be spaces between the function arguments and now there aren't. I wonder if there is some configuration mismatch in the make api-surface run that created the pervious version vs yours?
There was a problem hiding this comment.
There's still an inconsistency in the formatting here by removing the spaces between the arguments
What and why?
FFL-2510 —
FlagDetailslacked ametadatafield, making fields from the Precomputed Flags response (likeallocationKeyandextraLoggingprimitives) inaccessible to callers who usegetDetails. This PR addsmetadata: [String: AnyValue]toFlagDetailsand populates it from the flag assignment.How?
FlagAssignment.swift: AddedextraLogging: [String: AnyValue](decoded withdecodeIfPresent, defaults to[:]for backwards compatibility with older API responses)FlagDetails.swift: Addedpublic var metadata: [String: AnyValue](default[:], synthesizedEquatable—AnyValueis alreadyEquatable)FlagsClient.getDetails: IteratesextraLoggingprimitives intometadata(skipping"allocationKey"key), then writesallocationKeylast so the typed field always wins on collisionapi-surface-swift: Regenerated to include newFlagAssignment.extraLoggingandFlagDetails.metadataentriestestGetDetails_includesAllocationKeyInMetadata,testGetDetails_extraLoggingAllocationKeyDoesNotOverrideTypedAllocationKey,testGetDetails_errorPathsHaveEmptyMetadata, and new decoding tests forextraLoggingVerification
CI passed: Unit Tests (iOS) ✓, Unit Tests (tvOS/watchOS/visionOS) ✓, SPM Build (Swift 6.0/6.2) ✓, Smoke Tests ✓.
Review checklist
make api-surfacewhen adding new APIs