@@ -514,16 +514,20 @@ def validate_detokenize_request(logger, request):
514514 raise SkyflowError (SkyflowMessages .Error .EMPTY_TOKENS_LIST_VALUE .value , invalid_input_error_code )
515515
516516 for item in request .data :
517- if 'token' not in item or 'redaction' not in item :
518- raise SkyflowError (SkyflowMessages .Error .INVALID_TOKENS_LIST_VALUE .value (type (request .data )), invalid_input_error_code )
517+ if 'token' not in item :
518+ raise SkyflowError (SkyflowMessages .Error .INVALID_TOKENS_LIST_VALUE .value .format (type (request .data )),
519+ invalid_input_error_code )
520+
519521 token = item .get ('token' )
520- redaction = item .get ('redaction' )
522+ redaction = item .get ('redaction' , None )
521523
522524 if not isinstance (token , str ) or not token :
523- raise SkyflowError (SkyflowMessages .Error .INVALID_TOKEN_TYPE .value .format ("DETOKENIZE" ), invalid_input_error_code )
525+ raise SkyflowError (SkyflowMessages .Error .INVALID_TOKEN_TYPE .value .format ("DETOKENIZE" ),
526+ invalid_input_error_code )
524527
525- if not isinstance (redaction , RedactionType ) or not redaction :
526- raise SkyflowError (SkyflowMessages .Error .INVALID_REDACTION_TYPE .value .format (type (redaction )), invalid_input_error_code )
528+ if redaction is not None and not isinstance (redaction , RedactionType ):
529+ raise SkyflowError (SkyflowMessages .Error .INVALID_REDACTION_TYPE .value .format (type (redaction )),
530+ invalid_input_error_code )
527531
528532def validate_tokenize_request (logger , request ):
529533 parameters = request .values
0 commit comments