diff --git a/changelog.d/20250619_165702_jonathan.griffe_fix_gim_backwards_compatibility.md b/changelog.d/20250619_165702_jonathan.griffe_fix_gim_backwards_compatibility.md new file mode 100644 index 00000000..65258fce --- /dev/null +++ b/changelog.d/20250619_165702_jonathan.griffe_fix_gim_backwards_compatibility.md @@ -0,0 +1,3 @@ +### Changed + +- Set PolicyBreak's detector_name and detector_group_name fields as optional to fix backwards compatibility with the GitGuardian API diff --git a/pygitguardian/models.py b/pygitguardian/models.py index 0babee2c..4c7df6d7 100644 --- a/pygitguardian/models.py +++ b/pygitguardian/models.py @@ -216,8 +216,10 @@ class DiffKind(str, Enum): class PolicyBreakSchema(BaseSchema): break_type = fields.String(data_key="type", required=True) - detector_name = fields.String(required=True) - detector_group_name = fields.String(required=True) + detector_name = fields.String(required=False, load_default=None, dump_default=None) + detector_group_name = fields.String( + required=False, load_default=None, dump_default=None + ) documentation_url = fields.String( required=False, load_default=None, dump_default=None ) @@ -251,11 +253,11 @@ class PolicyBreak(FromDictWithBase): def __init__( self, break_type: str, - detector_name: str, - detector_group_name: str, policy: str, validity: str, matches: List[Match], + detector_name: Optional[str] = None, + detector_group_name: Optional[str] = None, documentation_url: Optional[str] = None, known_secret: bool = False, incident_url: Optional[str] = None, diff --git a/tests/test_models.py b/tests/test_models.py index c46eb5d4..1e068770 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -117,9 +117,6 @@ def test_document_handle_surrogates(self): PolicyBreak, { "type": "hello", - "detector_name": "hello", - "detector_group_name": "hello", - "documentation_url": None, "policy": "hello", "validity": "hey", "matches": [{"match": "hello", "type": "hello"}],