Skip to content

Commit ca872f4

Browse files
Vagoasdfgalvana
andcommitted
Eng 1695 skip access polling on erasure tasks (#6827)
Co-authored-by: Adrian Galvan <[email protected]>
1 parent 36280ec commit ca872f4

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o
2121

2222
## [Unreleased](https://github.com/ethyca/fides/compare/2.73.0..main)
2323

24+
### Changed
25+
- Updated border radius on our design system theme [#6512](https://github.com/ethyca/fides/pull/6813)
26+
- Simplified data category selection logic in monitor field list items by replacing `user_assigned_data_categories` with unified `preferred_data_categories` field [#6817](https://github.com/ethyca/fides/pull/6817)
27+
2428
## [2.73.0](https://github.com/ethyca/fides/compare/2.72.3..2.73.0)
2529

2630
### Added
@@ -52,6 +56,7 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o
5256
- Fixed incorrect positioning on "Add system" button on system inventory page when Compass was disabled [#6812](https://github.com/ethyca/fides/pull/6812)
5357
- Fixed missing reference value validation in SaaS requests to apply to all access requests [#6782](https://github.com/ethyca/fides/pull/6782)
5458
- Fixed an issue where some Special purpose vendors were displaying incorrectly in the TCF modal [#6830](https://github.com/ethyca/fides/pull/6830)
59+
- Added action guards on polling requests to avoid running access polling requests on erasure tasks [#6827](https://github.com/ethyca/fides/pull/6827)
5560

5661
### Changed
5762
- Switch to use `classify_params.llm_model_override` instead of `classify_params.model_override` in monitor config form [#6805](https://github.com/ethyca/fides/pull/6805)

src/fides/api/service/connectors/saas_connector.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,17 @@ def retrieve_data(
277277

278278
# Delegate async requests
279279
with get_db() as db:
280-
if async_dsr_strategy := _get_async_dsr_strategy(
281-
db, request_task, query_config, ActionType.access
282-
):
283-
284-
return async_dsr_strategy.async_retrieve_data(
285-
client=self.create_client(),
286-
request_task_id=request_task.id,
287-
query_config=query_config,
288-
input_data=input_data,
289-
)
280+
# Guard clause to ensure we only run async access requests for access requests
281+
if self.guard_access_request(policy):
282+
if async_dsr_strategy := _get_async_dsr_strategy(
283+
db, request_task, query_config, ActionType.access
284+
):
285+
return async_dsr_strategy.async_retrieve_data(
286+
client=self.create_client(),
287+
request_task_id=request_task.id,
288+
query_config=query_config,
289+
input_data=input_data,
290+
)
290291

291292
rows: List[Row] = []
292293
for read_request in read_requests:
@@ -349,6 +350,19 @@ def retrieve_data(
349350
self.unset_connector_state()
350351
return rows
351352

353+
def guard_access_request(self, policy: Policy) -> bool:
354+
"""
355+
Guard clause to ensure we only run async access requests
356+
if the access request is enabled and we are in an Access Request
357+
"""
358+
if (
359+
self.configuration.enabled_actions is None
360+
or ActionType.access in self.configuration.enabled_actions
361+
):
362+
if policy.get_rules_for_action(ActionType.access):
363+
return True
364+
return False
365+
352366
def _apply_output_template(
353367
self,
354368
param_value_maps: List[Dict[str, Any]],
@@ -773,10 +787,11 @@ def run_consent_request(
773787

774788
else:
775789
# follow the basic (global opt-in/out) SaaS consent flow
776-
should_opt_in, filtered_preferences = (
777-
build_user_consent_and_filtered_preferences_for_service(
778-
self.configuration.system, privacy_request, session, False
779-
)
790+
(
791+
should_opt_in,
792+
filtered_preferences,
793+
) = build_user_consent_and_filtered_preferences_for_service(
794+
self.configuration.system, privacy_request, session, False
780795
)
781796

782797
if should_opt_in is None:

tests/ops/service/privacy_request/test_request_runner_service.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,19 +2051,6 @@ def test_async_callback_erasure_request(
20512051
)
20522052

20532053
if dsr_version == "use_dsr_3_0":
2054-
# Access async task fired first
2055-
assert pr.access_tasks[1].status == ExecutionLogStatus.awaiting_processing
2056-
jwe_token = mock_send.call_args[0][0].headers["reply-to-token"]
2057-
auth_header = {"Authorization": "Bearer " + jwe_token}
2058-
# Post to callback URL to supply access results async
2059-
# This requeues task and proceeds downstream
2060-
response = api_client.post(
2061-
V1_URL_PREFIX + REQUEST_TASK_CALLBACK,
2062-
headers=auth_header,
2063-
json={"access_results": [{"id": 1, "user_id": "abcde", "state": "VA"}]},
2064-
)
2065-
assert response.status_code == 200
2066-
20672054
# Erasure task is also expected async results and is now paused
20682055
assert pr.erasure_tasks[1].status == ExecutionLogStatus.awaiting_processing
20692056
jwe_token = mock_send.call_args[0][0].headers["reply-to-token"]

0 commit comments

Comments
 (0)