ENG-3516: BE: Submission-time resolution of display_condition rules#8027
Merged
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. Additional details and impacted files@@ Coverage Diff @@
## main #8027 +/- ##
==========================================
+ Coverage 83.91% 85.15% +1.23%
==========================================
Files 636 637 +1
Lines 41864 41934 +70
Branches 4914 4927 +13
==========================================
+ Hits 35130 35707 +577
+ Misses 5611 5120 -491
+ Partials 1123 1107 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
39f61ff to
b8eadb4
Compare
2380e56 to
4f4a3fc
Compare
9120296 to
f7ef420
Compare
4f4a3fc to
a408dad
Compare
f7ef420 to
d2f5480
Compare
a222fd9 to
6b280f9
Compare
94b22a8 to
8a18b78
Compare
8ea0480 to
8c4f2db
Compare
8a18b78 to
28d12e0
Compare
vcruces
approved these changes
Apr 29, 2026
Contributor
vcruces
left a comment
There was a problem hiding this comment.
This looks great overall. I left a few comments, mostly questions or minor details. Approving!
d388813 to
fc878d5
Compare
0f35c91 to
a2d3fe3
Compare
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-3516
Description Of Changes
Add submission-time resolution and enforcement of
display_conditionrules on custom Privacy Center fields. Builds onDisplayConditionValidator(PR #8026, save-time): once a config is known to be well-formed, this PR resolves which fields are applicable given the submitted values and enforces the contract on incoming privacy request payloads.Two enforced rules:
display_conditionmust not be submitted;Wired into
PrivacyRequestService.create_privacy_requestso both public and authenticated creation paths reject violating payloads with 422 (viaPrivacyRequestError).Code Changes
src/fides/api/schemas/custom_field_display_evaluator.py:DisplayConditionViolation(ValueError)— raised on first contract breach; callers translate to layer-appropriate error.evaluate_submission(fields, submitted, condition_evaluator)— single public entry point._resolve_applicableruns a fixed-point: keep filtering the applicable set until it stops shrinking (handles chained conditions where field B's visibility depends on field A's, and A is itself gated off)._extract_submitted_valuenormalises raw JSON dicts,CustomPrivacyRequestFieldPydantic instances, and bare values into a single comparable shape.src/fides/service/privacy_request/privacy_request_service.py:_validate_field_visibilityresolves config + action for the request, filters outLocationCustomPrivacyRequestFieldentries (location handled separately), and callsevaluate_submissionwith aConditionEvaluator(self.db).create_privacy_requestnext to the existing required-location validation.DisplayConditionViolationis translated toPrivacyRequestError.Steps to Confirm
display_condition, POST a privacy request submitting that field with a value while the gating condition is false — expect 422 ("gated off … must not be submitted").display_conditionevaluates true, POST a privacy request omitting it — expect 422 ("Required field … is missing").LocationCustomPrivacyRequestFieldentries are still validated by the existing required-location path and not double-checked here.Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works