File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -221,22 +221,26 @@ def _guardrail_response_if_needed(self, response):
221221 return response
222222
223223 def _do_masking_if_needed (self , payload : Dict [str , Any ]) -> Dict [str , Any ]:
224- if self .EP_DONT_NEED_GUARDRAIL_AND_MASKING or not payload :
224+ if (
225+ self .EP_DONT_NEED_GUARDRAIL_AND_MASKING
226+ or not payload
227+ or type (payload ) is not dict
228+ ):
229+ return payload
230+
231+ do_masking = FORCE_MASKING or bool (payload .get ("anonymize" , False ))
232+ if not do_masking :
225233 return payload
226234
227235 audit_log = self ._begin_audit_log_if_needed (
228236 payload = payload ,
229237 prepare_audit_log = MASKING_WITH_AUDIT ,
230238 audit_type = "masking" ,
231239 )
232-
233- if FORCE_MASKING :
234- payload = self ._mask_whole_payload (
235- payload = payload ,
236- algorithms = MASKING_STRATEGY_PIPELINE ,
237- )
238- else :
239- return payload
240+ payload = self ._mask_whole_payload (
241+ payload = payload ,
242+ algorithms = MASKING_STRATEGY_PIPELINE ,
243+ )
240244
241245 self ._end_audit_log_if_needed (
242246 payload = payload ,
You can’t perform that action at this time.
0 commit comments