fix(aws-iac-mcp-server): scope describe_events to the failed OperationId#4280
Open
sergioperezcheco wants to merge 3 commits into
Open
Conversation
sergioperezcheco
requested review from
a team,
aemada-aws,
kdbrogan,
kumvprat and
vishaalmehrishi
as code owners
July 18, 2026 18:41
sergioperezcheco
force-pushed
the
sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id
branch
6 times, most recently
from
July 22, 2026 10:20
0136902 to
0d12738
Compare
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
force-pushed
the
sergioperezcheco/iac-mcp/cfn-troubleshooter-operation-id
branch
from
July 23, 2026 00:51
0d12738 to
b7da76a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4275
troubleshoot_cloudformation_deploymentalways returned an emptycloudformation_eventslist for a rolled-back stack (e.g. one inUPDATE_ROLLBACK_COMPLETE), even thoughraw_data.stack_statuscorrectly showed the failed state. The root cause is that the tool calleddescribe_eventswith onlyStackNameandFilters={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, sodescribe_eventsscoped toStackNamefinds nothing, and the actual failedUPDATE_STACK/CREATE_STACKevents are never surfaced.The fix reads
LastOperationsfrom thedescribe_stacksresponse, picks the most recent non-ROLLBACKoperation, and passes itsOperationIdtodescribe_events. WhenLastOperationsis absent (older API responses that predate the field) or only contains rollbacks, it falls back toStackNameso existing behavior is preserved.Added three regression tests covering the operation-scoped path, the
StackNamefallback, and the all-rollback fallback. The existing test suite passes unchanged (the old tests do not includeLastOperations, so they exercise the fallback branch), andcloudformation_deployment_troubleshooter.pynow 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.