vybekiit 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/bin.js +6457 -6312
  2. package/dist/global-skills/aws-serverless/SKILL.md +44 -44
  3. package/dist/global-skills/aws-serverless/assets/powertools-handler.py +2 -1
  4. package/dist/global-skills/aws-serverless/references/api-gateway.md +50 -470
  5. package/dist/global-skills/aws-serverless/references/architecture.md +47 -186
  6. package/dist/global-skills/aws-serverless/references/concurrency.md +44 -158
  7. package/dist/global-skills/aws-serverless/references/deployment.md +1 -1
  8. package/dist/global-skills/aws-serverless/references/event-sources.md +72 -391
  9. package/dist/global-skills/aws-serverless/references/lambda.md +69 -428
  10. package/dist/global-skills/aws-serverless/references/orchestration.md +65 -384
  11. package/dist/global-skills/aws-serverless/references/production.md +78 -415
  12. package/dist/global-skills/aws-serverless/references/troubleshooting.md +79 -626
  13. package/dist/global-skills/email-best-practices/.github/workflows/sync-skills.yml +30 -0
  14. package/dist/global-skills/email-best-practices/README.md +63 -0
  15. package/dist/global-skills/email-best-practices/references/accessibility.md +189 -0
  16. package/dist/global-skills/email-best-practices/references/compliance.md +125 -0
  17. package/dist/global-skills/email-best-practices/references/deliverability.md +121 -0
  18. package/dist/global-skills/email-best-practices/references/email-capture.md +129 -0
  19. package/dist/global-skills/email-best-practices/references/email-types.md +173 -0
  20. package/dist/global-skills/email-best-practices/references/list-management.md +157 -0
  21. package/dist/global-skills/email-best-practices/references/marketing-emails.md +115 -0
  22. package/dist/global-skills/email-best-practices/references/sending-reliability.md +155 -0
  23. package/dist/global-skills/email-best-practices/references/transactional-email-catalog.md +418 -0
  24. package/dist/global-skills/email-best-practices/references/transactional-emails.md +92 -0
  25. package/dist/global-skills/email-best-practices/references/webhooks-events.md +167 -0
  26. package/dist/global-skills/email-best-practices/tests/README.md +35 -0
  27. package/dist/global-skills/email-best-practices/tests/scenarios/01-spam-deliverability.md +46 -0
  28. package/dist/global-skills/email-best-practices/tests/scenarios/02-multi-region-compliance.md +48 -0
  29. package/dist/global-skills/email-best-practices/tests/scenarios/03-retry-idempotency.md +36 -0
  30. package/dist/global-skills/email-best-practices/tests/scenarios/04-webhook-bounce-handling.md +52 -0
  31. package/dist/global-skills/email-best-practices/tests/scenarios/05-new-saas-email-plan.md +51 -0
  32. package/dist/global-skills/instrument-feature-flags/references/usage.md +35 -0
  33. package/dist/global-skills/instrument-product-analytics/SKILL.md +1 -1
  34. package/dist/global-skills/instrument-product-analytics/references/android.md +36 -0
  35. package/dist/global-skills/instrument-product-analytics/references/configuration.md +1 -0
  36. package/dist/global-skills/instrument-product-analytics/references/flutter.md +37 -0
  37. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +3 -2
  38. package/dist/global-skills/instrument-product-analytics/references/usage.md +35 -0
  39. package/dist/global-skills/neon/SKILL.md +27 -20
  40. package/dist/global-skills/neon-ai-gateway/SKILL.md +68 -2
  41. package/dist/global-skills/neon-functions/SKILL.md +7 -7
  42. package/dist/global-skills/neon-object-storage/SKILL.md +2 -2
  43. package/dist/global-skills/neon-postgres/SKILL.md +5 -5
  44. package/dist/global-skills/neon-postgres/references/neon-sdk.md +262 -0
  45. package/dist/global-skills/neon-postgres-branches/SKILL.md +1 -1
  46. package/dist/global-skills/stripe-best-practices/SKILL.md +11 -6
  47. package/dist/global-skills/stripe-best-practices/references/billing.md +5 -0
  48. package/dist/global-skills/stripe-best-practices/references/payments.md +4 -2
  49. package/dist/global-skills/stripe-best-practices/references/tax.md +78 -8
  50. package/package.json +7 -7
@@ -1,711 +1,164 @@
1
1
  # Serverless Troubleshooting Reference
2
2
 
3
- Actionable error lookup tables: exact error string → cause → fix with CLI commands.
4
-
5
- ## Contents
6
-
7
- - [Quick fixes](#quick-fixes)
8
- - [Lambda Error Lookup](#lambda-error-lookup)
9
- - [API Gateway Error Lookup](#api-gateway-error-lookup)
10
- - [Step Functions Error Lookup](#step-functions-error-lookup)
11
- - [SAM/CDK Error Lookup](#samcdk-error-lookup)
12
- - [Timeout Debugging](#timeout-debugging)
13
- - [OOM Debugging](#out-of-memory-oom-debugging)
14
- - [Throttling Diagnosis](#throttling-diagnosis)
15
- - [CloudWatch Logs Insights Queries](#cloudwatch-logs-insights-queries)
16
- - [X-Ray Tracing](#x-ray-tracing)
17
-
18
- ---
3
+ Error → cause → fix, focused on non-obvious gotchas and exact CLI commands. The five most common fixes are first.
19
4
 
20
5
  ## Quick fixes
21
6
 
22
- ### 502 Bad Gateway from API Gateway
23
- Lambda proxy integration requires `{ statusCode: int, headers: {}, body: "string" }`.
24
- The `body` must be a string (`JSON.stringify()`), not an object. API Gateway returns 502 when it cannot parse the Lambda response — the function ran successfully but the response shape was wrong. Note: string statusCode (e.g., "200") is silently coerced to integer, and missing statusCode defaults to 200.
25
-
26
- ### CORS errors
27
- With Lambda proxy integration, Lambda must return CORS headers — the API Gateway console "Enable CORS" button does not work for Lambda proxy integration. Add `Access-Control-Allow-Origin`, `Access-Control-Allow-Methods`, `Access-Control-Allow-Headers` to every Lambda response including errors. For HTTP API, use the built-in `CorsConfiguration` instead. CORS is enforced by the browser, not the server — missing headers cause the browser to block the response even though the API call succeeded.
28
-
29
- ### Lambda timeout + API Gateway 504
30
- API Gateway has a hard integration timeout: REST API default 29s (configurable 50ms–29s; Regional/private APIs can request higher), HTTP API max 30s (can be lowered, cannot be raised). This is independent of Lambda's 15-min limit. The 504 means API Gateway gave up waiting, not that Lambda failed. For long operations, return 202 immediately, process via SQS or Step Functions, poll or use WebSocket for results.
31
-
32
- ### VPC Lambda cannot reach internet
33
- Lambda in a VPC needs a **private** subnet + NAT Gateway in a **public** subnet. Placing Lambda in a public subnet does NOT give it a public IP — Lambda never gets a public IP regardless of subnet type because Lambda's network interface is managed by the service and doesn't support public IP assignment. For AWS services only, use VPC endpoints (free for S3 and DynamoDB gateway endpoints).
34
-
35
- ### ImportModuleError / MODULE_NOT_FOUND
36
- Handler path doesn't match file structure, or dependencies weren't bundled. Lambda extracts code to `/var/task` and layers to `/opt` — if the handler path doesn't match the file's location relative to `/var/task`, the runtime can't find it. Python: `pip install -r requirements.txt -t ./package --platform manylinux2014_x86_64 --only-binary=:all:`. Node: verify `exports.handler` exists and `node_modules` is included. Use `sam build` to handle cross-platform packaging automatically.
7
+ - **502 Bad Gateway (proxy):** Lambda response must be `{ statusCode: int, headers: {}, body: "string" }`. `body` must be a `JSON.stringify`'d **string**, not an object. The function ran fine — only the response shape was wrong. (String statusCode is coerced. Under **HTTP API** payload format 2.0 a missing statusCode defaults to 200, but under **REST** proxy a missing statusCode is itself a malformed response and triggers the 502.)
8
+ - **CORS errors:** under proxy integration the **Lambda** returns CORS headers on **every** response including errors; the console "Enable CORS" button doesn't apply. HTTP API: use `CorsConfiguration`. CORS is browser-enforced — the API call itself succeeded. **Never use `AllowOrigin: '*'` in production** — wildcard CORS is a security risk (CWE-942); specify your exact domain (e.g. `https://app.example.com`).
9
+ - **504 from API Gateway:** integration timeout (REST 29s default; HTTP 30s max), independent of Lambda's 15-min limit. For long ops: return 202 immediately, process via SQS/Step Functions, poll or use WebSocket.
10
+ - **VPC Lambda can't reach internet:** needs **private** subnet + NAT Gateway in a **public** subnet. A public subnet does NOT give Lambda a public IP. For AWS services use VPC endpoints (free for S3/DynamoDB gateway endpoints).
11
+ - **ImportModuleError / MODULE_NOT_FOUND:** handler path doesn't match file structure, or deps weren't bundled for the right platform. Python: `pip install -r requirements.txt -t ./package --platform manylinux2014_x86_64 --only-binary=:all:`. Use `sam build` for cross-platform packaging.
37
12
 
38
13
  ---
39
14
 
40
- ## Lambda Error Lookup
41
-
42
- ### Runtime.ImportModuleError
43
-
44
- **Error:** `Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'lambda_function'`
45
- **Cause:** Handler references a module missing from the deployment package.
46
-
47
- ```bash
48
- pip install -r requirements.txt -t ./package
49
- cd package && zip -r ../deployment.zip . && cd .. && zip deployment.zip lambda_function.py
50
- # Or: sam build && sam deploy
51
- ```
52
-
53
- ### Runtime.HandlerNotFound
54
-
55
- **Error:** `Runtime.HandlerNotFound: Handler 'handler' missing on module 'function'`
56
- **Cause:** File exists but function/method name doesn't match handler setting.
57
-
58
- ```bash
59
- aws lambda update-function-configuration --function-name my-func --handler app.lambda_handler
60
- # Python: file.function Node: file.export Java: package.Class::method
61
- ```
62
-
63
- ### Task timed out
64
-
65
- **Error:** `Task timed out after 3.00 seconds`
66
- **Cause:** Execution exceeded configured timeout. Slow downstream calls, low memory/CPU, or VPC delays.
67
-
68
- ```bash
69
- aws lambda update-function-configuration --function-name my-func --timeout 30
70
- aws lambda update-function-configuration --function-name my-func --memory-size 512
71
- # Set SDK/HTTP timeouts shorter than Lambda timeout for meaningful errors
72
- ```
73
-
74
- ### Runtime.OutOfMemory (OOM)
75
-
76
- **Error:** `Runtime.OutOfMemory: ... signal: killed` or `Runtime exited without providing a reason`
77
- **Cause:** Function exceeded allocated memory — kernel sent SIGKILL.
78
-
79
- ```bash
80
- # Check REPORT lines: Max Memory Used vs Memory Size
81
- aws lambda update-function-configuration --function-name my-func --memory-size 1024
82
- # Stream large files instead of loading into memory; bound global caches
83
- ```
84
-
85
- ### AccessDeniedException
86
-
87
- **Error:** `AccessDeniedException: ... not authorized to perform: lambda:InvokeFunction`
88
- **Cause:** Calling IAM principal lacks `lambda:InvokeFunction` permission.
89
-
90
- ```bash
91
- aws lambda add-permission --function-name my-func \
92
- --statement-id AllowInvoke --action lambda:InvokeFunction \
93
- --principal s3.amazonaws.com --source-arn arn:aws:s3:::my-bucket
94
- ```
95
-
96
- ### TooManyRequestsException
97
-
98
- **Error:** `TooManyRequestsException: Rate Exceeded.`
99
- **Cause:** Function exceeded account concurrency limit (default 1,000).
100
-
101
- ```bash
102
- aws lambda get-account-settings
103
- aws service-quotas request-service-quota-increase \
104
- --service-code lambda --quota-code L-B99A9384 --desired-value 3000
105
- aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 100
106
- ```
107
-
108
- ### InvalidParameterValueException (size)
109
-
110
- **Error:** `Unzipped size must be smaller than 262144000 bytes`
111
- **Cause:** Package exceeds 50 MB zipped / 250 MB unzipped.
112
-
113
- ```bash
114
- find ./package -name "*.pyc" -delete && find ./package -name "*.dist-info" -type d -exec rm -rf {} +
115
- aws lambda publish-layer-version --layer-name my-deps --zip-file fileb://layer.zip --compatible-runtimes python3.13
116
- # Or upload via S3, or switch to container image packaging (10 GB limit)
117
- ```
118
-
119
- ### ETIMEDOUT (VPC)
120
-
121
- **Error:** `Error: connect ETIMEDOUT 176.32.98.189:443`
122
- **Cause:** VPC Lambda can't reach internet — missing NAT Gateway or VPC Endpoint.
123
-
124
- ```bash
125
- aws ec2 describe-route-tables --filters "Name=association.subnet-id,Values=subnet-xxx"
126
- aws ec2 create-route --route-table-id rtb-xxx --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-xxx
127
- # Or use VPC Endpoints for AWS services:
128
- aws ec2 create-vpc-endpoint --vpc-id vpc-xxx --service-name com.amazonaws.us-east-1.s3 --route-table-ids rtb-xxx
129
- ```
130
-
131
- ### MODULE_NOT_FOUND
132
-
133
- **Error:** `Error: Cannot find module 'my-module'`
134
- **Cause:** Node.js dependency missing — not bundled or built on incompatible platform.
135
-
136
- ```bash
137
- npm install --production
138
- sam build --use-container # for native modules
139
- unzip -l deployment.zip | grep my-module # verify inclusion
140
- ```
15
+ ## Lambda errors (gotchas)
141
16
 
142
17
  ### RecursiveInvocationException
143
18
 
144
- **Error:** `RecursiveInvocationException: Recursive invocation detected`
145
- **Cause:** Function writes to a resource that triggers itself again (~16 invocations before halt).
19
+ A function writes to a resource that re-triggers it (Lambda halts after ~16 loops).
146
20
 
147
21
  ```bash
148
- # Emergency stop
22
+ # Emergency stop:
149
23
  aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 0
150
- # Fix: use separate input/output buckets or prefix filters in trigger config
24
+ # Fix: separate input/output buckets, or prefix filters in the trigger config
151
25
  ```
152
26
 
153
- ### SnapStart Errors
27
+ ### SnapStart errors
154
28
 
155
- **Error:** `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException`
156
- **Cause:** SnapStart failed during snapshot — init threw exception or uses non-snapshottable resources (e.g., open network connections).
29
+ `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException` — init threw, or it uses non-snapshottable resources (open network connections).
157
30
 
158
31
  ```bash
159
32
  aws lambda get-function --function-name my-func --query 'Configuration.SnapStart'
160
- # Java: Use CRaC hooks — beforeCheckpoint() to close connections, afterRestore() to reopen
161
- # Python: Use snapshot_restore runtime hooks to re-establish connections after restore
162
- # .NET: Use SnapshotRestore register hooks for before-snapshot and after-restore actions
33
+ # Java: CRaC hooks — beforeCheckpoint() closes connections, afterRestore() reopens
34
+ # Python: snapshot_restore runtime hooks to re-establish connections after restore
35
+ # .NET: SnapshotRestore.Register hooks for before-snapshot / after-restore
163
36
  ```
164
37
 
165
38
  ### Sandbox.Timedout
166
39
 
167
- **Error:** `Sandbox.Timedout`
168
- **Cause:** Function exceeded its timeout. In newer runtimes, this covers both init-phase and invoke-phase timeouts. A suppressed init failure consumes the invoke timeout.
169
-
170
- ```bash
171
- aws lambda update-function-configuration --function-name my-func --timeout 60 --memory-size 1024
172
- # Move heavy initialization to lazy loading inside the handler
173
- ```
40
+ Exceeded the timeout. In newer runtimes this covers **both** init-phase and invoke-phase timeouts — a suppressed init failure consumes the invoke timeout. Move heavy init to lazy loading inside the handler; raise `--timeout`/`--memory-size`.
174
41
 
175
42
  ### ENILimitReachedException
176
43
 
177
- **Error:** `ENILimitReachedException`
178
- **Cause:** VPC reached network interface quota. Lambda Hyperplane ENIs have a default quota of 500 per VPC (see lambda.md); the overall VPC ENI quota is 5,000 per region. Check which limit applies.
44
+ VPC hit its network-interface quota. Two limits can apply — the Lambda-specific Hyperplane ENI-per-VPC quota and the broader VPC ENI-per-Region quota — so check which one was reached (Service Quotas / `describe-account-attributes`).
179
45
 
180
46
  ```bash
181
47
  aws service-quotas request-service-quota-increase --service-code vpc --quota-code L-DF5E4CA3 --desired-value 10000
182
- # Consolidate functions to use same subnet + security group combinations
48
+ # Consolidate functions onto the same subnet + security group combinations
183
49
  ```
184
50
 
185
- ### InvalidZipFileException
186
-
187
- **Error:** `InvalidZipFileException: Could not unzip uploaded file.`
188
- **Cause:** Invalid ZIP or handler nested in subdirectory instead of at root.
51
+ ### TooManyRequestsException / throttling
189
52
 
190
53
  ```bash
191
- unzip -t deployment.zip # verify integrity
192
- cd my-folder && zip -r ../deployment.zip . && cd .. # files at root, not nested
54
+ aws lambda get-account-settings
55
+ aws service-quotas request-service-quota-increase --service-code lambda --quota-code L-B99A9384 --desired-value 3000
56
+ aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 100
193
57
  ```
194
58
 
59
+ Throttle behavior by invocation type: **Sync (API GW)** → 429 (may surface as 500); **Async (S3, SNS)** → auto-retries up to 6h; **SQS** → returns to queue, backs off; **Kinesis/DynamoDB Streams** → retries batch, blocks shard.
60
+
195
61
  ### CodeStorageExceededException
196
62
 
197
- **Error:** `CodeStorageExceededException: Code storage limit exceeded.`
198
- **Cause:** Account exceeded 75 GB code storage per region (all versions + layers).
199
-
200
- ```bash
201
- aws lambda list-versions-by-function --function-name my-func
202
- aws lambda delete-function --function-name my-func --qualifier 1
203
- aws lambda list-layers # delete unused layers too
204
- ```
63
+ Account exceeded its per-Region code storage quota (unzipped; all versions + layers). Check the current limit with `aws service-quotas get-service-quota --service-code lambda --quota-code L-2ACBD22F` (it is adjustable and has changed over time). Delete old versions and unused layers (`aws lambda list-versions-by-function`, `delete-function --qualifier`).
205
64
 
206
65
  ---
207
66
 
208
- ## API Gateway Error Lookup
209
-
210
- ### Malformed Lambda Proxy Response (502)
211
-
212
- **Error:** `Malformed Lambda proxy response` → 502
213
- **Cause:** Lambda response missing required format — `body` must be a string, response must be a JSON object (not a plain string or array).
214
-
215
- ```python
216
- return {"statusCode": 200, "headers": {"Content-Type": "application/json"}, "body": json.dumps({"msg": "ok"})}
217
- ```
218
-
219
- ```javascript
220
- return { statusCode: 200, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ msg: "ok" }) };
221
- ```
222
-
223
- ### Missing Authentication Token (403)
224
-
225
- **Error:** `403 Forbidden: Missing Authentication Token`
226
- **Cause:** URL doesn't match any resource/method, or API not deployed to stage. Usually routing, not auth.
227
-
228
- ```bash
229
- aws apigateway create-deployment --rest-api-id abc123 --stage-name prod
230
- # Verify: https://{api-id}.execute-api.{region}.amazonaws.com/{stage}/{resource}
231
- ```
232
-
233
- ### Invalid Permissions on Lambda (500)
234
-
235
- **Error:** `Invalid permissions on Lambda function`
236
- **Cause:** API Gateway lacks `lambda:InvokeFunction` permission on the target function.
237
-
238
- ```bash
239
- aws lambda add-permission --function-name my-func --statement-id apigw-invoke \
240
- --action lambda:InvokeFunction --principal apigateway.amazonaws.com \
241
- --source-arn "arn:aws:execute-api:us-east-1:123456789012:api-id/*/GET/resource"
242
- ```
243
-
244
- ### Endpoint Request Timed Out (504)
245
-
246
- **Error:** `Endpoint request timed out` → 504
247
- **Cause:** Lambda didn't respond within 29s (REST) / 30s (HTTP) integration timeout.
248
-
249
- ```bash
250
- aws lambda update-function-configuration --function-name my-func --memory-size 1024
251
- # For long operations: return 202 immediately, process async, poll for results
252
- ```
253
-
254
- ### Authorizer Unauthorized (401)
255
-
256
- **Error:** `Unauthorized` (401)
257
- **Cause:** Lambda authorizer returned deny, threw error, or timed out.
258
-
259
- ```bash
260
- aws logs tail /aws/lambda/my-authorizer --since 1h --filter-pattern ERROR
261
- # Verify authorizer returns: { principalId, policyDocument: { Statement: [{ Effect: "Allow" }] } }
262
- ```
263
-
264
- ### WAF Access Denied (403)
265
-
266
- **Error:** `403 Forbidden` with `x-amzn-errortype: ForbiddenException`
267
- **Cause:** AWS WAF rule matched — IP denylist, rate limit, or injection detection.
268
-
269
- ```bash
270
- # Check WAF sampled requests in console to identify blocking rule
271
- # Test rules in Count mode before switching to Block
272
- ```
67
+ ## API Gateway errors (gotchas)
273
68
 
274
- ### CORS Errors
275
-
276
- **Error:** `blocked by CORS policy: No 'Access-Control-Allow-Origin' header`
277
- **Cause:** Lambda proxy integration must return CORS headers; HTTP APIs can configure at API level.
278
-
279
- ```yaml
280
- # SAM Globals
281
- Globals:
282
- Api:
283
- Cors:
284
- AllowOrigin: "'*'"
285
- AllowMethods: "'GET,POST,OPTIONS'"
286
- AllowHeaders: "'Content-Type,Authorization'"
287
- ```
288
-
289
- ```bash
290
- # HTTP API
291
- aws apigatewayv2 update-api --api-id abc123 \
292
- --cors-configuration AllowOrigins="*",AllowMethods="GET,POST",AllowHeaders="Content-Type"
293
- ```
294
-
295
- ### Internal Server Error — Lambda Throttled (500)
296
-
297
- **Error:** 500 with CloudWatch log `Lambda invocation failed with status 429`
298
- **Cause:** Lambda throttled but API Gateway surfaces as 500.
299
-
300
- ```bash
301
- # Increase Lambda concurrency (see TooManyRequestsException above)
302
- aws apigateway update-stage --rest-api-id abc123 --stage-name prod \
303
- --patch-operations op=replace,path=/*/*/throttling/rateLimit,value=1000
304
- ```
69
+ | Error | Cause | Fix |
70
+ |---|---|---|
71
+ | `403 Missing Authentication Token` | URL doesn't match a resource/method, or API not deployed | Usually routing, not auth — verify path and `create-deployment` to the stage |
72
+ | `Invalid permissions on Lambda function` (500) | API GW lacks `lambda:InvokeFunction` | `aws lambda add-permission --principal apigateway.amazonaws.com --source-arn "arn:aws:execute-api:...:api-id/*/GET/resource"` (add `--source-account <account-id>` to scope cross-service triggers like S3 to your account) |
73
+ | `Unauthorized` (401) | Lambda authorizer denied/errored/timed out | Check authorizer logs; verify it returns a valid Allow policy |
74
+ | `403` + `x-amzn-errortype: ForbiddenException` | WAF rule matched | Check WAF sampled requests; test rules in Count mode first |
75
+ | 500 with log `status 429` | Lambda throttled, surfaced as 500 | Increase Lambda concurrency |
305
76
 
306
77
  ---
307
78
 
308
- ## Step Functions Error Lookup
309
-
310
- ### States.TaskFailed
311
-
312
- **Error:** `States.TaskFailed`
313
- **Cause:** Task failed — unhandled Lambda exception, service error, or missing permissions.
314
-
315
- ```json
316
- "Retry": [{"ErrorEquals": ["States.TaskFailed","Lambda.ServiceException","Lambda.SdkClientException"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2.0}],
317
- "Catch": [{"ErrorEquals": ["States.TaskFailed"], "Next": "HandleError", "ResultPath": "$.error"}]
318
- ```
319
-
320
- ### States.Timeout
79
+ ## Step Functions errors
321
80
 
322
- **Error:** `States.Timeout`
323
- **Cause:** Task exceeded `TimeoutSeconds` or missed `HeartbeatSeconds` deadline.
324
-
325
- ```json
326
- {"Type": "Task", "Resource": "arn:aws:lambda:...", "TimeoutSeconds": 300, "HeartbeatSeconds": 60, "Next": "NextState"}
327
- ```
328
-
329
- ### States.DataLimitExceeded
330
-
331
- **Error:** `States.DataLimitExceeded`
332
- **Cause:** State input/output exceeded 256 KB. Cannot be caught by `States.ALL`.
333
-
334
- **Fix:** Store large data in S3, pass only S3 keys between states. Use `InputPath`/`OutputPath` to filter.
335
-
336
- ### ExecutionAlreadyExists
337
-
338
- **Error:** `ExecutionAlreadyExists`
339
- **Cause:** Execution name must be unique per state machine for 90 days.
340
-
341
- ```bash
342
- aws stepfunctions start-execution --state-machine-arn arn:aws:states:... \
343
- --name "exec-$(date +%s)" --input '{}'
344
- # Or omit --name for auto-generated names
345
- ```
346
-
347
- ### States.Permissions
348
-
349
- **Error:** `States.Permissions: insufficient privileges`
350
- **Cause:** Execution role lacks permission to invoke target service.
351
-
352
- ```bash
353
- aws iam list-attached-role-policies --role-name StepFunctionsRole
354
- # Add lambda:InvokeFunction, dynamodb:PutItem, etc. to the execution role
355
- ```
81
+ | Error | Cause / Fix |
82
+ |---|---|
83
+ | `States.TaskFailed` | Add `Retry` for `States.TaskFailed`/`Lambda.ServiceException`/`Lambda.SdkClientException`; `Catch` to a handler |
84
+ | `States.Timeout` | Set `TimeoutSeconds` (and `HeartbeatSeconds` for long tasks) |
85
+ | `States.DataLimitExceeded` | Input/output > 256 KiB — **cannot be caught by `States.ALL`**. Store in S3, pass keys |
86
+ | `ExecutionAlreadyExists` | Names unique per state machine for 90 days — use `--name "exec-$(date +%s)"` or omit `--name` |
87
+ | `States.Permissions` | Execution role lacks target-service permission |
356
88
 
357
89
  ---
358
90
 
359
- ## SAM/CDK Error Lookup
91
+ ## SAM/CDK errors
360
92
 
361
- ### Stale Build Cache
362
-
363
- **Error:** `sam build` uses old dependencies after updating requirements.txt, or `--clear-cache` flag unrecognized.
364
- **Cause:** SAM caches build artifacts. There is no `--clear-cache` flag.
93
+ ### Stale build cache
365
94
 
366
95
  ```bash
367
- sam build --no-cached # Force clean build (correct flag)
368
- rm -rf .aws-sam/cache # Or manually delete cache directory
96
+ sam build --no-cached # correct flag — there is NO --clear-cache
97
+ rm -rf .aws-sam/cache # or delete the cache directory
369
98
  ```
370
99
 
371
100
  ### PythonPipBuilder:ResolveDependencies
372
101
 
373
- **Error:** `PythonPipBuilder:ResolveDependencies - pip install returned a non-zero exit code`
374
- **Cause:** Dependency version conflicts or missing native libraries.
375
-
376
- ```bash
377
- sam build --use-container --no-cached
378
- # Use binary wheels: psycopg2-binary instead of psycopg2
379
- ```
380
-
381
- ### DockerBuildFailed
382
-
383
- **Error:** `DockerBuildFailed: Docker build failed.`
384
- **Cause:** Docker not running or Dockerfile errors.
385
-
386
- ```bash
387
- docker info # verify running
388
- sudo systemctl start docker # start if needed
389
- ```
390
-
391
- ### Cannot find module 'esbuild'
102
+ Version conflicts or missing native libs: `sam build --use-container --no-cached`; use binary wheels (`psycopg2-binary`).
392
103
 
393
- **Error:** `Cannot find module 'esbuild'`
394
- **Cause:** CDK `NodejsFunction` needs esbuild for bundling.
395
-
396
- ```bash
397
- npm install --save-dev esbuild
398
- ```
104
+ ### CDK NodejsFunction: `Cannot find module 'esbuild'`
399
105
 
400
- ### CREATE_FAILED
106
+ `npm install --save-dev esbuild`.
401
107
 
402
- **Error:** `CREATE_FAILED: AWS::Lambda::Function`
403
- **Cause:** Invalid runtime, missing S3 code, role not ready, or package too large.
108
+ ### CREATE_FAILED / UPDATE_ROLLBACK_FAILED
404
109
 
405
110
  ```bash
406
111
  aws cloudformation describe-stack-events --stack-name my-stack \
407
112
  --query "StackEvents[?ResourceStatus=='CREATE_FAILED'].[LogicalResourceId,ResourceStatusReason]" --output table
408
- ```
409
-
410
- ### UPDATE_ROLLBACK_FAILED
411
-
412
- **Error:** `UPDATE_ROLLBACK_FAILED`
413
- **Cause:** Update failed and rollback also failed — resource manually deleted or permissions changed.
414
-
415
- ```bash
416
- aws cloudformation continue-update-rollback --stack-name my-stack
113
+ # Rollback also failed (resource manually deleted / perms changed):
417
114
  aws cloudformation continue-update-rollback --stack-name my-stack --resources-to-skip MyFunction
418
115
  ```
419
116
 
420
- ### Security Constraints Not Satisfied
421
-
422
- **Error:** `Security Constraints Not Satisfied`
423
- **Cause:** SAM template missing required properties (Handler, Runtime, CodeUri).
424
-
425
- ```bash
426
- sam validate --lint
427
- ```
428
-
429
- ### CDK Bootstrap Required
117
+ ### Circular dependency
430
118
 
431
- **Error:** `This stack uses assets, so the toolkit stack must be deployed`
432
- **Cause:** Target account/region not bootstrapped.
119
+ `Circular dependency between resources: [MyFunction, MyRole, ...]` — break the cycle by giving the function an explicit `FunctionName` and referencing the hardcoded ARN (`!Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-function-name"`) instead of `!Ref`/`!GetAtt`, or extract the IAM role/policy into a separate resource.
433
120
 
434
- ```bash
435
- cdk bootstrap aws://123456789012/us-east-1
436
- ```
121
+ ### Other quick ones
437
122
 
438
- ### Circular Dependency
439
-
440
- **Error:** `Circular dependency between resources: [MyFunction, MyRole, ...]`
441
- **Cause:** Resources reference each other in a cycle.
442
-
443
- ```yaml
444
- # Break cycle: give the function an explicit name and hardcode the ARN
445
- MyFunction:
446
- Type: AWS::Lambda::Function
447
- Properties:
448
- FunctionName: my-function-name # explicit name
449
-
450
- MyRole:
451
- Type: AWS::IAM::Role
452
- Properties:
453
- Policies:
454
- - PolicyDocument:
455
- Statement:
456
- - Effect: Allow
457
- Action: lambda:InvokeFunction
458
- # No ${MyFunction} reference — no implicit dependency
459
- Resource: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-function-name"
460
- # Or restructure to eliminate the cycle (extract IAM role/policy into a separate resource)
461
- ```
123
+ - `DockerBuildFailed` → `docker info` / start Docker.
124
+ - `Security Constraints Not Satisfied` (missing Handler/Runtime/CodeUri) → `sam validate --lint`.
125
+ - `This stack uses assets, so the toolkit stack must be deployed` → `cdk bootstrap aws://ACCOUNT/REGION`.
462
126
 
463
127
  ---
464
128
 
465
- ## Timeout Debugging
466
-
467
- ```
468
- Function times out
469
- ├── INIT phase? (Sandbox.Timedout)
470
- │ ├── YES → Increase timeout + memory, lazy-load heavy deps
471
- │ └── NO → INVOKE phase
472
- │ ├── Timeout ≈ avg duration? → Set to 2-3x average
473
- │ ├── Calling external services? → Set SDK timeouts < Lambda timeout
474
- │ ├── CPU-bound? → Increase memory (1,769 MB = 1 vCPU)
475
- │ └── VPC? → Check NAT Gateway / security group / VPC Endpoints
476
- ```
477
-
478
- ```bash
479
- aws lambda get-function-configuration --function-name my-func --query '[Timeout,MemorySize]'
480
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Duration \
481
- --dimensions Name=FunctionName,Value=my-func --period 300 --statistics Average Maximum \
482
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
483
- # For percentiles, use a separate call:
484
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Duration \
485
- --dimensions Name=FunctionName,Value=my-func --period 300 --extended-statistics p99 \
486
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
487
- ```
488
-
489
- ---
490
-
491
- ## Out-of-Memory (OOM) Debugging
492
-
493
- ```
494
- Runtime.OutOfMemory / signal: killed
495
- ├── Check REPORT: Max Memory Used ≈ Memory Size? → OOM confirmed
496
- ├── Immediate? → Payload/dependency too large → increase memory
497
- ├── Gradual? → Memory leak → check global vars accumulating across warm invocations
498
- └── Fix: increase memory, stream large files, bound caches
499
- ```
500
-
501
- | Memory (MB) | vCPUs | Use Case |
502
- |-------------|-------|----------|
503
- | 128 | ~0.08 | Simple transforms |
504
- | 512 | ~0.3 | Moderate processing |
505
- | 1,769 | 1.0 | CPU-intensive single-threaded |
506
- | 3,538 | 2.0 | Multi-threaded |
507
- | 10,240 | ~5.8 | Heavy compute, ML inference |
508
-
509
- ---
510
-
511
- ## Throttling Diagnosis
512
-
513
- | Concept | Default | Notes |
514
- |---------|---------|-------|
515
- | Account concurrency | 1,000/region | Request increase via Service Quotas |
516
- | Reserved concurrency | None | Guarantees AND caps function concurrency |
517
- | Concurrency scaling rate | 1,000 envs/10s | Per function, uniform across regions |
518
-
519
- | Invocation Type | Throttle Behavior |
520
- |-----------------|-------------------|
521
- | Synchronous (API GW) | Returns 429 (API GW may show 500) |
522
- | Async (S3, SNS) | Auto-retries up to 6 hours |
523
- | SQS trigger | Returns to queue, backs off |
524
- | Kinesis/DDB Streams | Retries batch, blocks shard |
525
-
526
- ```bash
527
- aws lambda get-account-settings
528
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Throttles \
529
- --dimensions Name=FunctionName,Value=my-func --period 60 --statistics Sum \
530
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
531
- ```
532
-
533
- ---
534
-
535
- ## CloudWatch Logs Insights Queries
536
-
537
- Run against `/aws/lambda/FUNCTION_NAME`. For API Gateway, use the access log group.
538
-
539
- ### Cold Starts
540
-
541
- ```
542
- filter @type = "REPORT" | filter ispresent(@initDuration)
543
- | stats count() as coldStarts, avg(@initDuration) as avgInitMs, max(@initDuration) as maxInitMs, pct(@initDuration, 99) as p99InitMs by bin(1h)
544
- ```
545
-
546
- ### Cold Start Percentage
547
-
548
- ```
549
- filter @type = "REPORT"
550
- | stats count() as total, sum(ispresent(@initDuration)) as coldStarts, sum(ispresent(@initDuration)) * 100.0 / count() as pct by bin(1h)
551
- ```
552
-
553
- ### Errors by Type
554
-
555
- ```
556
- filter @message like /(?i)error|exception/
557
- | parse @message /(?<errorType>[A-Za-z]+Error|[A-Za-z]+Exception)/
558
- | stats count() as cnt by errorType | sort cnt desc
559
- ```
560
-
561
- ### Timeouts
562
-
563
- ```
564
- filter @message like /Task timed out/ | stats count() as timeouts by bin(1h) | sort bin desc
565
- ```
566
-
567
- ### Memory Utilization
568
-
569
- ```
570
- filter @type = "REPORT"
571
- | stats max(@memorySize/1e6) as provisionedMB, avg(@maxMemoryUsed/1e6) as avgUsedMB, max(@maxMemoryUsed/1e6) as maxUsedMB, pct(@maxMemoryUsed/1e6, 99) as p99UsedMB
572
- ```
573
-
574
- ### Out-of-Memory Detection (>90% memory)
575
-
576
- ```
577
- filter @type = "REPORT" | filter @maxMemoryUsed / @memorySize > 0.9
578
- | fields @timestamp, @requestId, @maxMemoryUsed/1e6 as usedMB, @memorySize/1e6 as allocatedMB | sort @timestamp desc | limit 50
579
- ```
580
-
581
- ### Overprovisioned Memory (<50% used)
582
-
583
- ```
584
- filter @type = "REPORT"
585
- | stats max(@memorySize/1e6) as provMB, max(@maxMemoryUsed/1e6) as peakMB, max(@maxMemoryUsed)*100.0/max(@memorySize) as pct
586
- | filter pct < 50
587
- ```
588
-
589
- ### Memory Growth (Leak Detection)
129
+ ## Diagnostics
590
130
 
591
- ```
592
- filter @type = "REPORT" | stats avg(@maxMemoryUsed/1e6) as avgMemMB by bin(5m) | sort bin asc
593
- ```
131
+ For systematic timeout investigation (config → logs → metrics → VPC → cold start → memory → downstream), use the **debugging-lambda-timeouts** skill (see SKILL.md routing).
594
132
 
595
- ### Latency Percentiles
133
+ CloudWatch Logs Insights run against `/aws/lambda/FUNCTION_NAME` (API Gateway uses the access log group). Useful fields on `@type = "REPORT"` lines: `@initDuration` (cold start), `@duration`, `@billedDuration`, `@maxMemoryUsed`, `@memorySize`. Examples:
596
134
 
597
135
  ```
598
- filter @type = "REPORT"
599
- | stats avg(@duration) as avg, pct(@duration,50) as p50, pct(@duration,90) as p90, pct(@duration,95) as p95, pct(@duration,99) as p99, max(@duration) as max by bin(1h)
600
- ```
601
-
602
- ### Slowest Invocations
136
+ # Cold start rate + init latency
137
+ filter @type="REPORT" | stats count() as total, sum(ispresent(@initDuration)) as coldStarts,
138
+ avg(@initDuration) as avgInitMs, pct(@initDuration,99) as p99InitMs by bin(1h)
603
139
 
604
- ```
605
- filter @type = "REPORT"
606
- | fields @timestamp, @requestId, @duration, @maxMemoryUsed/1000000 as memMB, ispresent(@initDuration) as coldStart
607
- | sort @duration desc | limit 20
608
- ```
140
+ # Out-of-memory (>90% used)
141
+ filter @type="REPORT" | filter @maxMemoryUsed/@memorySize > 0.9
142
+ | fields @timestamp, @requestId, @maxMemoryUsed/1e6 as usedMB | sort @timestamp desc
609
143
 
610
- ### API Gateway 5xx
144
+ # Latency percentiles
145
+ filter @type="REPORT" | stats pct(@duration,50) as p50, pct(@duration,90) as p90,
146
+ pct(@duration,99) as p99, max(@duration) as max by bin(1h)
611
147
 
612
- ```
148
+ # API Gateway 5xx (access log group)
613
149
  filter status >= 500 | stats count() as errors by status, path, httpMethod | sort errors desc
614
150
  ```
615
151
 
616
- ### API Gateway 5xx Over Time
617
-
618
- ```
619
- filter status >= 500 | stats count() by bin(5m) | sort bin desc
620
- ```
621
-
622
- ### Throttle Events
152
+ ### Memory ↔ vCPU (for OOM / CPU tuning)
623
153
 
624
- ```
625
- filter @message like /Rate Exceeded|TooManyRequestsException|Throttl/
626
- | fields @timestamp, @requestId, @message | sort @timestamp desc | limit 50
627
- ```
154
+ | Memory | vCPUs | Use case |
155
+ |---|---|---|
156
+ | 128 MB | ~0.08 | Simple transforms |
157
+ | 512 MB | ~0.3 | Moderate processing |
158
+ | 1,769 MB | 1.0 | CPU-intensive single-threaded |
159
+ | 3,538 MB | 2.0 | Multi-threaded |
160
+ | 10,240 MB | ~5.8 (up to 6 vCPU) | Heavy compute / ML inference |
628
161
 
629
- ### Billed Duration
162
+ ### X-Ray
630
163
 
631
- ```
632
- filter @type = "REPORT"
633
- | stats count() as invocations, sum(@billedDuration)/1000 as totalBilledSec, avg(@billedDuration) as avgBilledMs by bin(1d)
634
- ```
635
-
636
- ### Error Messages with Request IDs
637
-
638
- ```
639
- filter @message like /(?i)error|exception|fail/
640
- | fields @timestamp, @requestId, @message | sort @timestamp desc | limit 50
641
- ```
642
-
643
- ---
644
-
645
- ## X-Ray Tracing
646
-
647
- ### Enable in SAM
648
-
649
- ```yaml
650
- Globals:
651
- Function:
652
- Tracing: Active
653
- ```
654
-
655
- ### Enable in CDK
656
-
657
- ```typescript
658
- new lambda.Function(this, 'Fn', {
659
- tracing: lambda.Tracing.ACTIVE, // adds AWSXRayDaemonWriteAccess automatically
660
- });
661
- ```
662
-
663
- ### Required IAM
664
- `AWSXRayDaemonWriteAccess` managed policy on the execution role. SAM/CDK add this automatically.
665
-
666
- ### Default Sampling
667
- 1 request/second (reservoir) + 5% of additional requests.
668
-
669
- ### Instrument SDK Calls
670
-
671
- ```python
672
- from aws_xray_sdk.core import patch_all
673
- patch_all()
674
- ```
675
-
676
- ```javascript
677
- // SDK v3 (Node.js 18+)
678
- const { captureAWSv3Client } = require('aws-xray-sdk-core');
679
- const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
680
- const ddb = captureAWSv3Client(new DynamoDBClient({}));
681
- ```
682
-
683
- ### Query Traces
684
-
685
- ```bash
686
- aws xray get-trace-summaries --start-time $(date -u -d '1 hour ago' +%s) --end-time $(date -u +%s) \
687
- --filter-expression 'service("my-func") AND fault'
688
- aws xray batch-get-traces --trace-ids "1-xxx-yyy"
689
- ```
690
-
691
- ### Enable for API Gateway
692
-
693
- ```yaml
694
- Resources:
695
- MyApi:
696
- Type: AWS::Serverless::Api
697
- Properties:
698
- StageName: prod
699
- TracingEnabled: true
700
- ```
701
-
702
- ### Enable for Step Functions
703
-
704
- ```yaml
705
- Resources:
706
- MyStateMachine:
707
- Type: AWS::Serverless::StateMachine
708
- Properties:
709
- Tracing:
710
- Enabled: true
711
- ```
164
+ Enable via SAM `Tracing: Active` (Function) / `TracingEnabled: true` (Api) or CDK `tracing: lambda.Tracing.ACTIVE` (adds `AWSXRayDaemonWriteAccess` automatically). Default sampling: 1 req/s reservoir + 5%. Instrument SDK calls with `patch_all()` (Python) / `captureAWSv3Client` (Node).