Skip to content

[PM-40133] feat: Add Send Controls policy support and AnyCodable array/dictionary decoding#2868

Open
matt-livefront wants to merge 3 commits into
mainfrom
matt/PM-40133-send-controls-policy
Open

[PM-40133] feat: Add Send Controls policy support and AnyCodable array/dictionary decoding#2868
matt-livefront wants to merge 3 commits into
mainfrom
matt/PM-40133-send-controls-policy

Conversation

@matt-livefront

@matt-livefront matt-livefront commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

🎟️ 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 AnyCodable support for array types.

  • Adds PolicyType.sendControls (raw value 21) and completes its bidirectional SDK mapping in PolicyService+SdkMapping.swift.
  • Adds the pm-31885-send-controls feature flag to the FeatureFlag catalog (no client-side gating call site yet — this pass is plumbing only).
  • Fixes a decode error and closes the whole class of it: AnyCodable gains array (case array([AnyCodable])) and object/dictionary (case dictionary([String: AnyCodable])) support, so it now covers every JSON value kind. A policy data field containing a JSON array (e.g. Send Controls' allowedSendTypes) or a nested object no longer throws DecodingError.dataCorruptedError.

@matt-livefront matt-livefront added the ai-review Request a Claude code review label Jul 8, 2026
@matt-livefront matt-livefront requested a review from a team as a code owner July 8, 2026 19:03
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the Send Controls policy plumbing (PolicyType.sendControls raw value 21 with bidirectional SDK mapping, and the pm-31885-send-controls feature flag) alongside the AnyCodable array/dictionary support and its XCTest-to-Swift-Testing conversion. The AnyCodable decode ordering is correct — scalars, null, and string are attempted before the structural array and dictionary cases, which are mutually exclusive by JSON container type — and encode covers all seven cases. The PolicyType mapping is symmetric in both directions, and sendControls was correctly removed from the .unknown fallthrough. The stale doc comment previously flagged on PolicyService+SdkMapping.swift has been addressed in this diff.

Code Review Details

No new findings. The feature flag is placed alphabetically in both the declaration and allCases, the new arrayValue/dictionaryValue accessors are symmetric with the existing ones, and doubleValue/intValue correctly return nil for the container cases. Test coverage is thorough for decode, encode, and accessor paths.

Comment thread BitwardenShared/Core/Vault/Services/PolicyService+SdkMapping.swift
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.98%. Comparing base (85f3884) to head (5d839bd).

Files with missing lines Patch % Lines
...wardenKit/Core/Platform/Utilities/AnyCodable.swift 90.00% 2 Missing ⚠️
...Shared/Core/Platform/Models/Enum/FeatureFlag.swift 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

ai-review Request a Claude code review app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant