From cfb155ac449cd3f7db27491590710e5906c57941 Mon Sep 17 00:00:00 2001 From: Kydoimos97 Date: Wed, 10 Jun 2026 12:55:30 -0600 Subject: [PATCH] feat(incident): add --needs-wrench-bot-check flag to update command Exposes the NeedsWrenchBotCheck custom field via the CLI so scripts can toggle it without dropping to the raw Datadog API. Setting this field to yes triggers the ec2-bot triage webhook for the incident. Follows the same pattern as --is-duplicate, --triage-completed, and --needs-human-attention. Includes a test asserting the correct field key and capitalized value are sent in the PATCH payload. --- puppy_kit/commands/incident.py | 13 +++++++++++++ tests/commands/test_incident.py | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/puppy_kit/commands/incident.py b/puppy_kit/commands/incident.py index 6c82f97..b567b9b 100644 --- a/puppy_kit/commands/incident.py +++ b/puppy_kit/commands/incident.py @@ -597,6 +597,12 @@ def create_incident(title, description, severity, team, assignee, customer_impac type=click.Choice(["yes", "no"]), help="Is duplicate flag", ) +@click.option( + "--needs-wrench-bot-check", + default=None, + type=click.Choice(["yes", "no"]), + help="NeedsWrenchBotCheck flag — set to yes to trigger the triage webhook", +) @click.option("--teams", multiple=True, default=None, help="Team names (repeatable)") @click.option("--services", multiple=True, default=None, help="Service names (repeatable)") @click.option( @@ -621,6 +627,7 @@ def update_incident( needs_human_attention, triage_completed, is_duplicate, + needs_wrench_bot_check, teams, services, related_incidents, @@ -648,6 +655,7 @@ def update_incident( needs_human_attention, triage_completed, is_duplicate, + needs_wrench_bot_check, teams, services, related_incidents, @@ -719,6 +727,11 @@ def update_incident( "type": "dropdown", "value": is_duplicate.capitalize(), } + if needs_wrench_bot_check is not None: + field_data["NeedsWrenchBotCheck"] = { + "type": "dropdown", + "value": needs_wrench_bot_check.capitalize(), + } if teams: field_data["teams"] = {"type": "autocomplete", "value": list(teams)} if services: diff --git a/tests/commands/test_incident.py b/tests/commands/test_incident.py index 42531e1..f57e2a8 100644 --- a/tests/commands/test_incident.py +++ b/tests/commands/test_incident.py @@ -434,6 +434,28 @@ def test_update_incident_assignee(self, mock_client, runner): assert "muhammad" in result.output mock_client.incidents.update_incident.assert_called_once() + def test_update_incident_needs_wrench_bot_check(self, mock_client, runner): + """Test that --needs-wrench-bot-check sets NeedsWrenchBotCheck in field_data.""" + inc = _make_incident("inc-1", "Service outage", "SEV-3", "active") + response = Mock(data=inc) + mock_client.incidents.update_incident.return_value = response + + mock_cfg = Mock(site="datadoghq.com", api_key="test-api-key", app_key="test-app-key") + with patch("puppy_kit.commands.incident.get_datadog_client", return_value=mock_client): + with patch("puppy_kit.commands.incident.load_config", return_value=mock_cfg): + with patch("puppy_kit.commands.incident.requests.patch") as mock_patch: + mock_patch.return_value = Mock(raise_for_status=Mock()) + result = runner.invoke( + incident, + ["update", "inc-1", "--needs-wrench-bot-check", "yes"], + ) + + assert result.exit_code == 0, f"Command failed: {result.output}" + assert "updated" in result.output + _, kwargs = mock_patch.call_args + sent_fields = kwargs["json"]["data"]["attributes"]["fields"] + assert sent_fields["NeedsWrenchBotCheck"] == {"type": "dropdown", "value": "Yes"} + class TestSetStatusIncident: def test_set_status_table(self, runner):