@@ -332,6 +332,15 @@ class V20IssueCredSchemaCore(AdminAPIMessageTracingSchema):
332332 )
333333 },
334334 )
335+ auto_remove_on_failure = fields .Bool (
336+ required = False ,
337+ metadata = {
338+ "description" : (
339+ "Whether to remove the credential exchange record on failure"
340+ " (overrides --no-preserve-failed-exchange-records configuration setting)"
341+ )
342+ },
343+ )
335344 comment = fields .Str (
336345 required = False ,
337346 allow_none = True ,
@@ -393,6 +402,15 @@ class V20CredRequestFreeSchema(AdminAPIMessageTracingSchema):
393402 )
394403 },
395404 )
405+ auto_remove_on_failure = fields .Bool (
406+ required = False ,
407+ metadata = {
408+ "description" : (
409+ "Whether to remove the credential exchange record on failure"
410+ " (overrides --no-preserve-failed-exchange-records configuration setting)"
411+ )
412+ },
413+ )
396414 comment = fields .Str (
397415 required = False ,
398416 allow_none = True ,
@@ -512,6 +530,16 @@ class V20CredRequestRequestSchema(OpenAPISchema):
512530 )
513531 },
514532 )
533+ auto_remove_on_failure = fields .Bool (
534+ required = False ,
535+ dump_default = False ,
536+ metadata = {
537+ "description" : (
538+ "Whether to remove the credential exchange record on failure"
539+ " (overrides --no-preserve-failed-exchange-records configuration setting)"
540+ )
541+ },
542+ )
515543
516544
517545class V20CredIssueRequestSchema (OpenAPISchema ):
@@ -735,6 +763,10 @@ async def credential_exchange_create(request: web.BaseRequest):
735763 auto_remove = body .get (
736764 "auto_remove" , not profile .settings .get ("preserve_exchange_records" )
737765 )
766+ auto_remove_on_failure = body .get (
767+ "auto_remove_on_failure" ,
768+ profile .settings .get ("no_preserve_failed_exchange_records" ),
769+ )
738770 if not filt_spec :
739771 raise web .HTTPBadRequest (reason = "Missing filter" )
740772 trace_msg = body .get ("trace" )
@@ -763,6 +795,7 @@ async def credential_exchange_create(request: web.BaseRequest):
763795 connection_id = None ,
764796 cred_proposal = cred_proposal ,
765797 auto_remove = auto_remove ,
798+ auto_remove_on_failure = auto_remove_on_failure ,
766799 )
767800 except (StorageError , BaseModelError ) as err :
768801 raise web .HTTPBadRequest (reason = err .roll_up ) from err
@@ -1338,6 +1371,10 @@ async def credential_exchange_send_free_request(request: web.BaseRequest):
13381371 auto_remove = body .get (
13391372 "auto_remove" , not profile .settings .get ("preserve_exchange_records" )
13401373 )
1374+ auto_remove_on_failure = body .get (
1375+ "auto_remove_on_failure" ,
1376+ profile .settings .get ("no_preserve_failed_exchange_records" ),
1377+ )
13411378 trace_msg = body .get ("trace" )
13421379 holder_did = body .get ("holder_did" )
13431380
@@ -1362,6 +1399,7 @@ async def credential_exchange_send_free_request(request: web.BaseRequest):
13621399 cred_ex_record = V20CredExRecord (
13631400 connection_id = connection_id ,
13641401 auto_remove = auto_remove ,
1402+ auto_remove_on_failure = auto_remove_on_failure ,
13651403 cred_proposal = cred_proposal .serialize (),
13661404 initiator = V20CredExRecord .INITIATOR_SELF ,
13671405 role = V20CredExRecord .ROLE_HOLDER ,
@@ -1433,9 +1471,16 @@ async def credential_exchange_send_bound_request(request: web.BaseRequest):
14331471 auto_remove = body .get (
14341472 "auto_remove" , not profile .settings .get ("preserve_exchange_records" )
14351473 )
1474+ auto_remove_on_failure = body .get (
1475+ "auto_remove_on_failure" ,
1476+ profile .settings .get ("no_preserve_failed_exchange_records" ),
1477+ )
14361478 except JSONDecodeError :
14371479 holder_did = None
14381480 auto_remove = not profile .settings .get ("preserve_exchange_records" )
1481+ auto_remove_on_failure = profile .settings .get (
1482+ "no_preserve_failed_exchange_records"
1483+ )
14391484
14401485 cred_ex_id = request .match_info ["cred_ex_id" ]
14411486
@@ -1479,6 +1524,7 @@ async def credential_exchange_send_bound_request(request: web.BaseRequest):
14791524
14801525 # assign the auto_remove flag from above...
14811526 cred_ex_record .auto_remove = auto_remove
1527+ cred_ex_record .auto_remove_on_failure = auto_remove_on_failure
14821528
14831529 cred_manager = V20CredManager (profile )
14841530 cred_ex_record , cred_request_message = await cred_manager .create_request (
0 commit comments