[PM-40133] feat: Add Send Controls policy support and AnyCodable array/dictionary decoding#2868
[PM-40133] feat: Add Send Controls policy support and AnyCodable array/dictionary decoding#2868matt-livefront wants to merge 3 commits into
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the Send Controls policy plumbing ( Code Review DetailsNo new findings. The feature flag is placed alphabetically in both the declaration and |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2868 +/- ##
==========================================
- Coverage 81.27% 78.98% -2.30%
==========================================
Files 1027 1150 +123
Lines 66109 73426 +7317
==========================================
+ Hits 53733 57993 +4260
- Misses 12376 15433 +3057 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fedemkr
left a comment
There was a problem hiding this comment.
Looks good, just one question.
| /// The wrapped value is an array of `AnyCodable` values. | ||
| case array([AnyCodable]) | ||
|
|
||
| /// The wrapped value is a bool value. | ||
| case bool(Bool) | ||
|
|
||
| /// The wrapped value is a keyed dictionary of `AnyCodable` values. | ||
| case dictionary([String: AnyCodable]) | ||
|
|
There was a problem hiding this comment.
🤔 Do we need to consider the possibility of array/dictionary values being nil? E.g.
let json = #"{"something": {"a": 1, "bOptional": null}}"#
I guess it would be more likely in a dictionary's key/value to have a potential nil value, on arrays it seems a bit far-fetched but raising it just in case.
There was a problem hiding this comment.
Good question, that is handled by AnyCodable.null:
ios/BitwardenKit/Core/Platform/Utilities/AnyCodable.swift
Lines 21 to 22 in 5d839bd
(lldb) po dictionary
▿ 1 element
▿ 0 : 2 elements
- key : "something"
▿ value : AnyCodable
▿ dictionary : 2 elements
▿ 0 : 2 elements
- key : "a"
▿ value : AnyCodable
- int : 1
▿ 1 : 2 elements
- key : "bOptional"
- value : BitwardenKit.AnyCodable.null
🎟️ Tracking
PM-40133
📔 Objective
Adds the new Send Controls policy and feature flag. This also fixes a JSON decoding error for the policy since we didn't previously have
AnyCodablesupport for array types.PolicyType.sendControls(raw value21) and completes its bidirectional SDK mapping inPolicyService+SdkMapping.swift.pm-31885-send-controlsfeature flag to theFeatureFlagcatalog (no client-side gating call site yet — this pass is plumbing only).AnyCodablegains array (case array([AnyCodable])) and object/dictionary (case dictionary([String: AnyCodable])) support, so it now covers every JSON value kind. A policydatafield containing a JSON array (e.g. Send Controls'allowedSendTypes) or a nested object no longer throwsDecodingError.dataCorruptedError.