From 1c1293bf8092d1d30e64401c4d9bb59abf019949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Delion?= Date: Mon, 1 Dec 2025 14:23:09 +0100 Subject: [PATCH 1/2] feat(assignee): Extend features and fix bugs reagarding assignee and filtering by user Issue: APPAI-54 --- .../src/gg_api_core/tools/list_incidents.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/gg_api_core/src/gg_api_core/tools/list_incidents.py b/packages/gg_api_core/src/gg_api_core/tools/list_incidents.py index 430177e..60f7fc3 100644 --- a/packages/gg_api_core/src/gg_api_core/tools/list_incidents.py +++ b/packages/gg_api_core/src/gg_api_core/tools/list_incidents.py @@ -56,6 +56,10 @@ def _build_filter_info(params: "ListIncidentsParams") -> dict[str, Any]: filters["severity"] = [sev.value if hasattr(sev, "value") else sev for sev in params.severity] if params.validity: filters["validity"] = [v.value if hasattr(v, "value") else v for v in params.validity] + if params.assignee_id: + filters["assignee_id"] = params.assignee_id + if params.assignee_email: + filters["assignee_email"] = params.assignee_email return filters @@ -67,6 +71,10 @@ def _build_suggestion(params: "ListIncidentsParams", incidents_count: int) -> st # Explain what's being filtered if params.mine: suggestions.append("Incidents are filtered to show only those assigned to current user") + if params.assignee_id: + suggestions.append(f"Incidents are filtered by assignee ID: {params.assignee_id}") + if params.assignee_email: + suggestions.append(f"Incidents are filtered by assignee email: {params.assignee_email}") if params.exclude_tags: excluded_tag_names = [tag.name if hasattr(tag, "name") else tag for tag in params.exclude_tags] @@ -129,6 +137,14 @@ class ListIncidentsParams(BaseModel): default=False, description="If True, fetch only incidents assigned to the current user. Set to False to get all incidents.", ) + assignee_id: int | None = Field( + default=None, + description="Filter by assignee member ID. Cannot be used together with 'mine'.", + ) + assignee_email: str | None = Field( + default=None, + description="Filter by assignee email address. Cannot be used together with 'mine'.", + ) severity: list[str | IncidentSeverity] | None = Field( default=cast(list[str | IncidentSeverity], DEFAULT_SEVERITIES), description="Filter by severity (list of severity names)", @@ -196,7 +212,18 @@ async def list_incidents(params: ListIncidentsParams) -> ListIncidentsResult | L if params.mine: member = await client.get_current_member() - api_params["assignee_email"] = member["email"] + current_user_email = member["email"] + if params.assignee_email and params.assignee_email != current_user_email: + return ListIncidentsError( + error=f"Conflict: 'mine=True' implies assignee_email='{current_user_email}', " + f"but assignee_email='{params.assignee_email}' was explicitly provided. " + "Please use either 'mine=True' or an explicit 'assignee_email', not both with different values." + ) + api_params["assignee_email"] = current_user_email + if params.assignee_id: + api_params["assignee_id"] = params.assignee_id + if params.assignee_email and not params.mine: + api_params["assignee_email"] = params.assignee_email if params.from_date: api_params["date_after"] = params.from_date From 39b51ae8e08ab166282ce5ae3de0797425f4b8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Delion?= Date: Mon, 1 Dec 2025 14:33:03 +0100 Subject: [PATCH 2/2] fix(tests): Fix an isolation issue between tests and GITGUARDIAN_PERSONAL_ACCESS_TOKEN env variable Issue: # --- tests/conftest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index f3cb4ad..3c98210 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,7 +60,11 @@ def mock_gitguardian_client(): @pytest.fixture(autouse=True) def mock_env_vars(): """Automatically mock environment variables for all tests.""" - with patch.dict(os.environ, {"GITGUARDIAN_URL": "https://test.api.gitguardian.com"}): + env_overrides = { + "GITGUARDIAN_URL": "https://test.api.gitguardian.com", + "GITGUARDIAN_PERSONAL_ACCESS_TOKEN": "", # Clear PAT to test OAuth paths + } + with patch.dict(os.environ, env_overrides): yield