Skip to content

fix: set PolicyBreak's detector_name and detector_group_name as optio… #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions pygitguardian/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}],
Expand Down
Loading