Skip to content

Commit 833134a

Browse files
committed
fix(manage_incident): correctly route the tool actions
remove assign action from the manage_incident tool improve docstring for the tool
1 parent 4b3043e commit 833134a

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

packages/gg_api_core/src/gg_api_core/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,12 @@ async def resolve_incident(self, incident_id: str) -> dict[str, Any]:
11521152
logger.info(f"Resolving incident {incident_id}")
11531153
return await self._request("POST", f"/incidents/secrets/{incident_id}/resolve")
11541154

1155-
async def ignore_incident(self, incident_id: str, ignore_reason: str = None) -> dict[str, Any]:
1155+
async def ignore_incident(self, incident_id: str, ignore_reason: str | None = None) -> dict[str, Any]:
11561156
"""Ignore a secret incident.
11571157
11581158
Args:
11591159
incident_id: ID of the secret incident
1160-
ignore_reason: Reason for ignoring (test_credential, false_positive, etc.)
1160+
ignore_reason: Reason for ignoring (test_credential, false_positive, low_risk, invalid)
11611161
11621162
Returns:
11631163
Status of the operation

packages/gg_api_core/src/gg_api_core/tools/manage_incident.py

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,65 @@ class ManageIncidentParams(BaseModel):
1313
"""Parameters for managing an incident."""
1414

1515
incident_id: str | int = Field(description="ID of the secret incident to manage")
16-
action: Literal["assign", "unassign", "resolve", "ignore", "reopen"] = Field(
17-
description="Action to perform on the incident"
16+
action: Literal["unassign", "resolve", "ignore", "reopen"] = Field(
17+
description="Action to perform on the incident: 'unassign' removes any assigned member, 'resolve' marks the incident as resolved, 'ignore' marks as ignored (use with ignore_reason), 'reopen' reopens a resolved or ignored incident"
1818
)
19-
assignee_id: str | int | None = Field(
20-
default=None, description="ID of the member to assign the incident to (required for 'assign' action)"
21-
)
22-
ignore_reason: str | None = Field(
19+
ignore_reason: Literal["test_credential", "false_positive", "low_risk", "invalid"] | None = Field(
2320
default=None,
24-
description="Reason for ignoring (test_credential, false_positive, etc.) (used with 'ignore' action)",
21+
description="Reason for ignoring the incident. Only used with 'ignore' action. Options: 'test_credential' (secret is for testing), 'false_positive' (not a real secret), 'low_risk' (secret poses minimal risk), 'invalid' (secret is invalid/inactive)",
2522
)
26-
mine: bool = Field(default=False, description="If True, use the current user's ID for the assignee_id")
2723

2824

2925
async def manage_private_incident(params: ManageIncidentParams) -> dict[str, Any]:
3026
"""
31-
Manage a secret incident (assign, unassign, resolve, ignore, reopen).
27+
Perform lifecycle management actions on a secret incident.
28+
29+
This tool allows you to change the state of a secret incident through various actions:
30+
- 'unassign': Remove the assigned member from an incident (useful when reassigning or leaving unassigned)
31+
- 'resolve': Mark an incident as resolved (typically after the secret has been rotated/revoked)
32+
- 'ignore': Mark an incident as ignored with a reason (test_credential, false_positive, low_risk, or invalid)
33+
- 'reopen': Reopen a previously resolved or ignored incident
34+
35+
Note: To assign an incident to a member, use the dedicated 'assign_incident' tool instead.
3236
3337
Args:
34-
params: ManageIncidentParams model containing incident management configuration
38+
params: ManageIncidentParams containing:
39+
- incident_id: The ID of the incident to manage
40+
- action: The lifecycle action to perform (unassign, resolve, ignore, or reopen)
41+
- ignore_reason: Required when action is 'ignore'. One of: test_credential, false_positive, low_risk, invalid
3542
3643
Returns:
37-
Updated incident data
44+
Dictionary containing the updated incident data from the API
45+
46+
Raises:
47+
ToolError: If the action fails or if an invalid action is provided
3848
"""
3949
client = get_client()
4050
logger.debug(f"Managing incident {params.incident_id} with action: {params.action}")
4151

4252
try:
43-
# Make the API call
44-
result = await client.manage_incident(
45-
incident_id=params.incident_id,
46-
action=params.action,
47-
assignee_id=params.assignee_id,
48-
ignore_reason=params.ignore_reason,
49-
mine=params.mine,
50-
)
51-
52-
logger.debug(f"Managed incident {params.incident_id}")
53+
# Route the action to the appropriate client method
54+
if params.action == "unassign":
55+
result = await client.unassign_incident(incident_id=str(params.incident_id))
56+
57+
elif params.action == "resolve":
58+
result = await client.resolve_incident(incident_id=str(params.incident_id))
59+
60+
elif params.action == "ignore":
61+
result = await client.ignore_incident(
62+
incident_id=str(params.incident_id), ignore_reason=params.ignore_reason
63+
)
64+
65+
elif params.action == "reopen":
66+
result = await client.reopen_incident(incident_id=str(params.incident_id))
67+
68+
else:
69+
raise ToolError(f"Unknown action: {params.action}")
70+
71+
logger.debug(f"Successfully managed incident {params.incident_id} with action: {params.action}")
5372
return result
73+
except ToolError:
74+
raise
5475
except Exception as e:
5576
logger.error(f"Error managing incident: {str(e)}")
5677
raise ToolError(f"Error: {str(e)}")
@@ -77,7 +98,7 @@ async def update_incident_status(params: UpdateIncidentStatusParams) -> dict[str
7798
logger.debug(f"Updating incident {params.incident_id} status to {params.status}")
7899

79100
try:
80-
result = await client.update_incident_status(incident_id=params.incident_id, status=params.status)
101+
result = await client.update_incident(incident_id=str(params.incident_id), status=params.status)
81102
logger.debug(f"Updated incident {params.incident_id} status to {params.status}")
82103
return result
83104
except Exception as e:

0 commit comments

Comments
 (0)