Skip to content

Commit 122b2a3

Browse files
authored
Merge branch 'main' into feat/dsql-query-plan-explainability
2 parents 990e6c8 + 95381e8 commit 122b2a3

34 files changed

Lines changed: 13974 additions & 49 deletions

File tree

plugins/aws-serverless/skills/aws-lambda-durable-functions/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Load the appropriate reference file based on what the user is working on:
104104
- **Testing**, **local testing**, **cloud testing**, **test runner**, or **flaky tests** -> see [testing-patterns.md](references/testing-patterns.md)
105105
- **Deployment**, **CloudFormation**, **CDK**, **SAM**, **log groups**, **deploy**, or **infrastructure** -> see [deployment-iac.md](references/deployment-iac.md)
106106
- **Advanced patterns**, **GenAI agents**, **completion policies**, **step semantics**, or **custom serialization** -> see [advanced-patterns.md](references/advanced-patterns.md)
107-
- **troubleshooting**, **stuck execution**, **failed execution**, **debug execution ID**, or **execution history** -> see [troubleshooting-executions.md](references/troubleshooting-executions.md)
107+
- **troubleshooting**, **stuck execution**, **failed execution**, **debug execution ID**, **execution history**, **execution error**, **why did my execution fail**, **execution timed out**, **callback not received**, **diagnose execution**, or **root cause execution** -> see [troubleshooting-executions.md](references/troubleshooting-executions.md)
108108

109109
## Quick Reference
110110

plugins/aws-serverless/skills/aws-lambda-durable-functions/references/troubleshooting-executions.md

Lines changed: 133 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ When spawning the troubleshooting agent, provide:
1919

2020
```
2121
Diagnose durable function execution issue:
22-
- Function: <function-name>:<alias> (must be qualified ARN)
23-
- Execution ID: <execution-id>
22+
- Durable Execution ARN: <durable-execution-arn>
23+
- Region: <region> (infer from ARN)
2424
2525
CRITICAL SAFETY RULES:
2626
- This is READ-ONLY diagnosis
@@ -29,31 +29,144 @@ CRITICAL SAFETY RULES:
2929
- Only suggest manual remediation if user explicitly requests it
3030
3131
Steps:
32-
1. Run: aws lambda get-durable-execution-history --function-name <function> --execution-id <id>
33-
2. Analyze execution status (RUNNING/SUCCEEDED/FAILED/TIMED_OUT)
34-
3. Check for stuck operations (PENDING/RUNNING status)
35-
4. Identify failed operations and error messages
36-
5. Calculate operation durations and timeline
37-
6. Diagnose specific issue:
38-
- Stuck in WAIT_FOR_CALLBACK: Extract callback ID, suggest manual callback
39-
- Failed operations: Show error and retry attempts
40-
- Timeout: Calculate total duration, identify slow operations
41-
- Unexpected behavior: Compare operation order with expected flow
42-
7. Provide specific recommendations and next steps
4332
44-
Use jq for JSON parsing and analysis.
33+
0. If the user provides a function name + alias (e.g., my-function:prod) instead of a full ARN:
34+
- Resolve the alias to a version: aws lambda get-alias --function-name <functionName> --name <alias> --region <region> --query 'FunctionVersion' --output text
35+
- List executions for that function: aws lambda list-durable-executions-by-function --function-name <functionName>:<version> --region <region>
36+
- Ask the user to identify the execution, or use the most recent one.
37+
38+
1. Fetch the execution history directly:
39+
Run: aws lambda get-durable-execution-history --durable-execution-arn <durable-execution-arn> --region <region> --include-execution-data
40+
41+
2. If the command succeeds, analyze and provide a user-friendly diagnosis:
42+
a. Report the execution status (RUNNING/SUCCEEDED/FAILED/STOPPED/TIMED_OUT)
43+
b. Identify the root cause by looking for these key events in the history:
44+
45+
**Execution-level failures:**
46+
- `ExecutionFailed` — entire execution crashed; extract the error and cause fields
47+
- `ExecutionTimedOut` — the execution exceeded its configured timeout
48+
- `ExecutionStopped` — execution was manually stopped via StopDurableExecution
49+
50+
**Context and step failures:**
51+
- `ContextFailed` — a child context threw an unhandled error; check the parent context for what triggered it
52+
- `StepFailed` — an individual step failed; includes RetryDetails (CurrentAttempt, NextAttemptDelaySeconds) showing retry state
53+
54+
**Callback issues:**
55+
- `CallbackStarted` with a Timeout field — confirms a timeout was registered; correlate with any subsequent `CallbackTimedOut`
56+
- `CallbackTimedOut` — a timeout fired but may not have been caught by the function code
57+
- `CallbackFailed` — the callback was resolved with an error
58+
59+
**Chained invocation failures:**
60+
- `ChainedInvokeFailed` — a chained (child) durable execution failed
61+
- `ChainedInvokeTimedOut` — a chained execution exceeded its timeout
62+
- `ChainedInvokeStopped` — a chained execution was stopped
63+
64+
**Other signals:**
65+
- `WaitCancelled` — a scheduled wait was cancelled before completing
66+
- `InvocationCompleted` with an Error field — the Lambda invocation itself errored (e.g., runtime crash)
67+
68+
**Diagnosis patterns:**
69+
- Failed operations: Show the EXACT error message verbatim in a code block
70+
- Stuck in WAIT_FOR_CALLBACK: Extract callback ID, show how long it's been waiting
71+
- Timeout: Show which operation was running when timeout occurred
72+
- Unexpected behavior: Compare operation order with expected flow
73+
c. Calculate operation durations and timeline
74+
d. Provide a clear, plain-language explanation of what went wrong and why
75+
76+
3. If the command fails:
77+
- Execution not found: Tell the user the execution ID may be incorrect or the execution may have been purged. Ask them to verify the ARN.
78+
- Permissions/network error: check that your caller identity has lambda:GetDurableExecutionHistory on the function ARN.
79+
- In either case, direct them to the console as a fallback (see step 4)
80+
81+
4. ALWAYS provide a direct link to the Execution Details page in the Lambda console.
82+
Parse the ARN (arn:<partition>:lambda:<region>:<accountId>:function:<functionName>:<functionVersion>/durable-execution/<executionName>/<invocationId>)
83+
to extract region, functionName, functionVersion, executionName, and invocationId, then construct:
84+
https://<region>.console.aws.amazon.com/lambda/home?region=<region>#/functions/<functionName>/versions/<functionVersion>/executions/<executionName>/<invocationId>
85+
86+
Frame it as: "**[View this execution in the console](<url>)**"
87+
88+
5. Provide specific, actionable next steps based on the diagnosis.
89+
90+
6. If unable to determine the root cause from execution history:
91+
- Provide the console link (step 4)
92+
- Offer to fetch the log group and pull relevant logs:
93+
a. Get the log group:
94+
aws lambda get-function-configuration --function-name <functionName>:<functionVersion> --region <region> --query 'LoggingConfig.LogGroup'
95+
b. Query logs filtered by invocation ID (parsed from the ARN):
96+
aws logs filter-log-events --log-group-name <logGroup> --region <region> --filter-pattern '"<invocationId>"'
97+
c. If the function uses SDK structured logging (context.logger), query for step-level logs.
98+
Use execution start time from step 2 as start-time, and execution end time (or current time if still running) as end-time:
99+
QUERY_ID=$(aws logs start-query --log-group-name <logGroup> --region <region> \
100+
--start-time <startEpoch> --end-time <endEpoch> \
101+
--query-string 'fields @timestamp, @message | filter executionName = "<executionName>" | sort @timestamp asc' \
102+
--query 'queryId' --output text)
103+
Then poll for results:
104+
aws logs get-query-results --query-id $QUERY_ID --region <region>
105+
- If unable to determine the log group, ask the user to check the function's logs
106+
107+
OUTPUT FORMAT:
108+
- Lead with a short summary: "Your execution [status] because [reason]."
109+
- Show the error message verbatim in a code block if one exists.
110+
- Explain what this means in plain language.
111+
- Provide the console link for visual debugging.
112+
- List recommended next steps.
113+
114+
Use jq for JSON parsing if available, otherwise use --query (AWS CLI built-in JMESPath) or python -m json.tool.
45115
```
46116

47117
## Example Usage
48118

119+
````
120+
User: "My durable function execution abc-123 is stuck on my-function:prod in us-west-2"
121+
122+
Agent: [Runs get-durable-execution-history command]
123+
Agent: [Analyzes with jq queries]
124+
125+
Claude: Your execution is **waiting for an external callback** that hasn't arrived yet.
126+
127+
The operation `wait-for-approval` has been pending since 2026-02-14 (3 days).
128+
It will time out in 12 hours if no callback is received.
129+
130+
Callback ID: `xyz789`
131+
132+
**[View this execution in the console](https://us-west-2.console.aws.amazon.com/lambda/home?region=us-west-2#/functions/my-function/versions/3/executions/abc-123/inv-456)**
133+
49134
```
50-
User: "My durable function execution abc-123 is stuck on my-function:prod"
135+
https://us-west-2.console.aws.amazon.com/lambda/home?region=us-west-2#/functions/my-function/versions/3/executions/abc-123/inv-456
136+
```
137+
138+
**Next steps:**
139+
1. Check if the approval email was sent to the recipient
140+
2. Verify the callback ID `xyz789` was included in the email
141+
3. If you'd like me to help send the callback manually, let me know
142+
````
143+
144+
````
145+
User: "Execution def-456 failed on order-processor:live in us-east-1"
51146
52-
Claude: [Spawns Task agent with troubleshooting instructions]
53147
Agent: [Runs get-durable-execution-history command]
54148
Agent: [Analyzes with jq queries]
55-
Agent: [Returns: "Execution stuck in WAIT_FOR_CALLBACK operation 'wait-for-approval'.
56-
Callback ID: xyz789. Waiting since 2026-02-14. Timeout in 12 hours.
57-
Recommendation: Check if approval email was sent, or manually send callback."]
58-
Claude: [Presents findings and offers to send manual callback if needed]
149+
150+
Claude: Your execution **failed** at the `charge-payment` step after 3 retry attempts.
151+
152+
Error message:
153+
154+
```
155+
PaymentGatewayError: Card declined - insufficient funds (code: card_declined)
59156
```
157+
158+
This means the payment provider rejected the charge. The durable function
159+
retried 3 times with exponential backoff but the error persisted because
160+
it's a permanent failure (not a transient network issue).
161+
162+
**[View this execution in the console](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/order-processor/versions/5/executions/def-456/inv-789)**
163+
164+
```
165+
https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/order-processor/versions/5/executions/def-456/inv-789
166+
```
167+
168+
**Next steps:**
169+
1. This is a business logic failure, not an infrastructure issue
170+
2. Consider adding a non-retryable error classification for `card_declined`
171+
3. Implement a compensation step to release the reserved inventory
172+
````

0 commit comments

Comments
 (0)