Skip to content

fix(aws-iac-mcp-server): scope describe_events to the failed OperationId#4280

Open
sergioperezcheco wants to merge 3 commits into
awslabs:mainfrom
sergioperezcheco:sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id
Open

fix(aws-iac-mcp-server): scope describe_events to the failed OperationId#4280
sergioperezcheco wants to merge 3 commits into
awslabs:mainfrom
sergioperezcheco:sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id

Conversation

@sergioperezcheco

@sergioperezcheco sergioperezcheco commented Jul 18, 2026

Copy link
Copy Markdown

Fixes #4275


troubleshoot_cloudformation_deployment always returned an empty cloudformation_events list for a rolled-back stack (e.g. one in UPDATE_ROLLBACK_COMPLETE), even though raw_data.stack_status correctly showed the failed state. The root cause is that the tool called describe_events with only StackName and Filters={FailedEvents: true}.

CloudFormation groups events by Operation ID — every update, rollback, etc. is its own operation. On a rolled-back stack the latest operation is the (successful) ROLLBACK, so describe_events scoped to StackName finds nothing, and the actual failed UPDATE_STACK/CREATE_STACK events are never surfaced.

The fix reads LastOperations from the describe_stacks response, picks the most recent non-ROLLBACK operation, and passes its OperationId to describe_events. When LastOperations is absent (older API responses that predate the field) or only contains rollbacks, it falls back to StackName so existing behavior is preserved.

Added three regression tests covering the operation-scoped path, the StackName fallback, and the all-rollback fallback. The existing test suite passes unchanged (the old tests do not include LastOperations, so they exercise the fallback branch), and cloudformation_deployment_troubleshooter.py now has 100% line coverage.

Assisted-by: Hermes Agent

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@sergioperezcheco
sergioperezcheco force-pushed the sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id branch 6 times, most recently from 0136902 to 0d12738 Compare July 22, 2026 10:20
Sergio Perez and others added 3 commits July 23, 2026 08:51
troubleshoot_cloudformation_deployment always returned an empty
cloudformation_events list for a rolled-back stack because it called
describe_events with only StackName and FailedEvents=true. CloudFormation
groups events by Operation ID, and the latest operation on a rolled-back stack
is the (successful) ROLLBACK, so the failed UPDATE/CREATE events are never
returned.

Read LastOperations from describe_stacks, pick the most recent non-rollback
operation, and pass its OperationId to describe_events. When LastOperations is
absent (older API behavior) or only contains rollbacks, fall back to StackName
to preserve existing behavior.

Fixes awslabs#4275

Assisted-by: Hermes Agent
Signed-off-by: sergioperezcheco <checo520@outlook.com>
@sergioperezcheco
sergioperezcheco force-pushed the sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id branch from 0d12738 to b7da76a Compare July 23, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

aws-iac-mcp-server: troubleshoot_cloudformation_deployment returns empty events (describe_events not scoped to failed OperationId)

1 participant