Skip to content

Commit 79a992c

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 4134666 commit 79a992c

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

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

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,63 @@ 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(incident_id=str(params.incident_id), ignore_reason=params.ignore_reason)
62+
63+
elif params.action == "reopen":
64+
result = await client.reopen_incident(incident_id=str(params.incident_id))
65+
66+
else:
67+
raise ToolError(f"Unknown action: {params.action}")
68+
69+
logger.debug(f"Successfully managed incident {params.incident_id} with action: {params.action}")
5370
return result
71+
except ToolError:
72+
raise
5473
except Exception as e:
5574
logger.error(f"Error managing incident: {str(e)}")
5675
raise ToolError(f"Error: {str(e)}")
@@ -77,7 +96,7 @@ async def update_incident_status(params: UpdateIncidentStatusParams) -> dict[str
7796
logger.debug(f"Updating incident {params.incident_id} status to {params.status}")
7897

7998
try:
80-
result = await client.update_incident_status(incident_id=params.incident_id, status=params.status)
99+
result = await client.update_incident(incident_id=str(params.incident_id), status=params.status)
81100
logger.debug(f"Updated incident {params.incident_id} status to {params.status}")
82101
return result
83102
except Exception as e:

0 commit comments

Comments
 (0)