@@ -475,10 +475,10 @@ def has_permission(self, request, view):
475475 if engagement := converted_dict .get ("engagement" ):
476476 # Validate the resolved engagement's parent chain matches any provided identifiers
477477 if (product := converted_dict .get ("product" )) and engagement .product_id != product .id :
478- msg = f' The resolved engagement is associated with product " { engagement . product . name } ", not with product " { converted_dict . get ( "product_name" ) } "'
478+ msg = " The provided identifiers are inconsistent — the engagement does not belong to the specified product."
479479 raise ValidationError (msg )
480480 if (engagement_name := converted_dict .get ("engagement_name" )) and engagement .name != engagement_name :
481- msg = f' The resolved engagement is named " { engagement . name } ", not " { engagement_name } "'
481+ msg = " The provided identifiers are inconsistent — the engagement name does not match the specified engagement."
482482 raise ValidationError (msg )
483483 return user_has_permission (
484484 request .user , engagement , Permissions .Import_Scan_Result ,
@@ -787,17 +787,17 @@ def has_permission(self, request, view):
787787 if test := converted_dict .get ("test" ):
788788 # Validate the resolved test's parent chain matches any provided identifiers
789789 if (product := converted_dict .get ("product" )) and test .engagement .product_id != product .id :
790- msg = f' The resolved test is associated with product " { test . engagement . product . name } ", not with product " { converted_dict . get ( "product_name" ) } "'
790+ msg = " The provided identifiers are inconsistent — the test does not belong to the specified product."
791791 raise ValidationError (msg )
792792 if (engagement := converted_dict .get ("engagement" )) and test .engagement_id != engagement .id :
793- msg = f' The resolved test is associated with engagement " { test . engagement . name } ", not with engagement " { converted_dict . get ( "engagement_name" ) } "'
793+ msg = " The provided identifiers are inconsistent — the test does not belong to the specified engagement."
794794 raise ValidationError (msg )
795795 # Also validate by name when the objects were not resolved (e.g. names that match no existing record)
796796 if not converted_dict .get ("product" ) and (product_name := converted_dict .get ("product_name" )) and test .engagement .product .name != product_name :
797- msg = f' The resolved test is associated with product " { test . engagement . product . name } ", not with product " { product_name } "'
797+ msg = " The provided identifiers are inconsistent — the test does not belong to the specified product."
798798 raise ValidationError (msg )
799799 if not converted_dict .get ("engagement" ) and (engagement_name := converted_dict .get ("engagement_name" )) and test .engagement .name != engagement_name :
800- msg = f' The resolved test is associated with engagement " { test . engagement . name } ", not with engagement " { engagement_name } "'
800+ msg = " The provided identifiers are inconsistent — the test does not belong to the specified engagement."
801801 raise ValidationError (msg )
802802 return user_has_permission (
803803 request .user , test , Permissions .Import_Scan_Result ,
@@ -1207,7 +1207,7 @@ def check_auto_create_permission(
12071207 if engagement :
12081208 # Validate the resolved engagement's parent chain matches any provided names
12091209 if product is not None and engagement .product_id != product .id :
1210- msg = f' The resolved engagement is associated with product " { engagement . product . name } ", not with product " { product_name } "'
1210+ msg = " The provided identifiers are inconsistent — the engagement does not belong to the specified product."
12111211 raise ValidationError (msg )
12121212 return user_has_permission (
12131213 user , engagement , Permissions .Import_Scan_Result ,
0 commit comments