ENG-3515: BE: new custom privacy center field types (checkbox, checkbox_group, textarea)#7977
Open
mikeGarifullin wants to merge 4 commits intomainfrom
Open
ENG-3515: BE: new custom privacy center field types (checkbox, checkbox_group, textarea)#7977mikeGarifullin wants to merge 4 commits intomainfrom
mikeGarifullin wants to merge 4 commits intomainfrom
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (84.98%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #7977 +/- ##
==========================================
+ Coverage 84.95% 84.98% +0.02%
==========================================
Files 631 632 +1
Lines 41185 41256 +71
Branches 4781 4786 +5
==========================================
+ Hits 34989 35061 +72
- Misses 5110 5112 +2
+ Partials 1086 1083 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fix two failing tests that pass value=None / value="" to exercise the
persist path's drop-None-and-empty filter. Pydantic was rejecting None
at construction time (4 validation errors against every MultiValue
union branch) before persist could run.
Making value Optional lets "no value supplied" be expressed; the
existing persist filter (`if item.value or isinstance(item.value, bool)`)
already drops None and empty strings before writing to the DB, and
cache_custom_privacy_request_fields already skips None entries.
Fixes:
tests/ops/models/privacy_request/test_consent.py::
TestConsentRequestCustomFieldFunctions::
test_persist_custom_privacy_request_fields_preserves_bool_and_drops_empty
tests/ops/models/privacy_request/test_privacy_request.py::
TestPrivacyRequestCustomFieldFunctions::
test_persist_custom_privacy_request_fields_preserves_bool_and_drops_empty
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
910a0b8 to
3f4a310
Compare
erosselli
reviewed
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket ENG-3515
Description Of Changes
Adds three new custom privacy center form field types —
checkbox,checkbox_group, andtextarea— to the public privacy-center config schema. Also widensMultiValueto acceptStrictBoolso boolean checkbox values round-trip through identity caching and persistence without being coerced toint.Key subtlety:
StrictBoolmust precedeStrictIntin theMultiValueunion becauseboolis a subclass ofintin Python — if the order were reversed, pydantic would acceptTrue/Falseon the int branch and silently drop the bool type. An inline comment and regression tests pin this.Two latent
if item.value:/if not value:guards on the persist and hash paths would have swallowed legitimateFalsecheckbox values. Switched tois None/is not Nonechecks with matching comments.Code Changes
src/fides/api/schemas/privacy_center_config.py— addcheckbox,checkbox_group,textareatoCustomPrivacyRequestField.field_type. Extendvalidate_field_type_constraints:checkbox_grouprequiresoptionscheckboxandtextarearejectoptionsmultiselectandcheckbox_grouprejecthidden=True(default_value is str-only, can't represent a list)src/fides/api/schemas/redis_cache.py—MultiValueacceptsStrictBool(union order:StrictBool, StrictInt, StrictStr, List[...]). Inline comment explains the ordering rationale.src/fides/api/schemas/privacy_request.py— updateIdentityValuedocstring to includebool.src/fides/api/models/privacy_preference.py—bcrypt_hash_value/hash_valueswitched fromif not value:toif value is None:soFalsehashes rather than being treated as "no value".src/fides/api/models/privacy_request/privacy_request.pyand.../consent.py—persist_custom_privacy_request_fieldsswitched fromif item.value:toif item.value is not None:for the same reason on both PrivacyRequest and ConsentRequest paths.tests/ops/schemas/test_identity_schema.py— parametrized bool round-trip tests onLabeledIdentity+CustomPrivacyRequestFieldpinning StrictBool ordering; replaced brittle "4 validation errors" count assertion with a loc-based one.tests/ops/schemas/test_privacy_center_config.py— parametrized valid/invalid tests for new field types and the new validator rules.changelog/7977-new-custom-privacy-center-field-types.yaml— added.Steps to Confirm
pytest tests/ops/schemas/test_privacy_center_config.py tests/ops/schemas/test_identity_schema.pyand confirm all pass.PUT /api/v1/plus/privacy-center-configwith an action whosecustom_privacy_request_fieldsincludes each new type:{ "agree": {"label": "I confirm", "field_type": "checkbox", "required": true}, "data_types": {"label": "Which data?", "field_type": "checkbox_group", "options": ["Profile", "Orders"]}, "context": {"label": "Notes", "field_type": "textarea"} }PUTreturns 4xx for:checkbox_groupwithoutoptionscheckboxortextareawithoptionsmultiselectorcheckbox_groupwithhidden=True/api/v1/privacy-request) containing acheckboxcustom field withvalue: false. Confirm the value persists asFalsein theCustomPrivacyRequestFieldtable (SELECT encrypted_value FROM customprivacyrequestfield WHERE field_name=...) and is not dropped.Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works