vybekiit 0.7.0 → 0.7.2

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 (94) hide show
  1. package/dist/bin.js +1697 -562
  2. package/dist/global-skills/add-ai/SKILL.md +1 -1
  3. package/dist/global-skills/add-analytics/SKILL.md +1 -1
  4. package/dist/global-skills/add-blog/SKILL.md +1 -1
  5. package/dist/global-skills/add-crud/SKILL.md +1 -1
  6. package/dist/global-skills/add-files/SKILL.md +1 -1
  7. package/dist/global-skills/add-images/SKILL.md +1 -1
  8. package/dist/global-skills/add-language/SKILL.md +1 -1
  9. package/dist/global-skills/add-notifications/SKILL.md +1 -1
  10. package/dist/global-skills/add-realtime/SKILL.md +1 -1
  11. package/dist/global-skills/add-route/SKILL.md +1 -1
  12. package/dist/global-skills/add-search/SKILL.md +1 -1
  13. package/dist/global-skills/add-signin/SKILL.md +1 -1
  14. package/dist/global-skills/add-teams/SKILL.md +1 -1
  15. package/dist/global-skills/add-upload/SKILL.md +1 -1
  16. package/dist/global-skills/aws-serverless/SKILL.md +44 -44
  17. package/dist/global-skills/aws-serverless/assets/powertools-handler.py +1 -2
  18. package/dist/global-skills/aws-serverless/references/api-gateway.md +470 -50
  19. package/dist/global-skills/aws-serverless/references/architecture.md +186 -47
  20. package/dist/global-skills/aws-serverless/references/concurrency.md +158 -44
  21. package/dist/global-skills/aws-serverless/references/deployment.md +1 -1
  22. package/dist/global-skills/aws-serverless/references/event-sources.md +391 -72
  23. package/dist/global-skills/aws-serverless/references/lambda.md +428 -69
  24. package/dist/global-skills/aws-serverless/references/orchestration.md +384 -65
  25. package/dist/global-skills/aws-serverless/references/production.md +415 -78
  26. package/dist/global-skills/aws-serverless/references/troubleshooting.md +626 -79
  27. package/dist/global-skills/back-up-my-code/SKILL.md +1 -1
  28. package/dist/global-skills/buy-domain/SKILL.md +1 -1
  29. package/dist/global-skills/check-safety/SKILL.md +1 -1
  30. package/dist/global-skills/configure-capabilities/SKILL.md +1 -1
  31. package/dist/global-skills/connect-account/SKILL.md +1 -1
  32. package/dist/global-skills/connect-account-backend/SKILL.md +1 -1
  33. package/dist/global-skills/design-my-data/SKILL.md +1 -1
  34. package/dist/global-skills/doctor/SKILL.md +1 -1
  35. package/dist/global-skills/feedback/SKILL.md +63 -0
  36. package/dist/global-skills/go-live/SKILL.md +1 -1
  37. package/dist/global-skills/harden/SKILL.md +1 -1
  38. package/dist/global-skills/instrument-feature-flags/references/usage.md +0 -35
  39. package/dist/global-skills/instrument-product-analytics/SKILL.md +1 -1
  40. package/dist/global-skills/instrument-product-analytics/references/android.md +0 -36
  41. package/dist/global-skills/instrument-product-analytics/references/configuration.md +0 -1
  42. package/dist/global-skills/instrument-product-analytics/references/flutter.md +0 -37
  43. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +2 -3
  44. package/dist/global-skills/instrument-product-analytics/references/usage.md +0 -35
  45. package/dist/global-skills/manifest.json +2 -1
  46. package/dist/global-skills/neon/SKILL.md +20 -27
  47. package/dist/global-skills/neon-ai-gateway/SKILL.md +2 -68
  48. package/dist/global-skills/neon-functions/SKILL.md +7 -7
  49. package/dist/global-skills/neon-object-storage/SKILL.md +2 -2
  50. package/dist/global-skills/neon-postgres/SKILL.md +5 -5
  51. package/dist/global-skills/neon-postgres-branches/SKILL.md +1 -1
  52. package/dist/global-skills/onboarding/SKILL.md +1 -1
  53. package/dist/global-skills/plan-my-idea/SKILL.md +1 -1
  54. package/dist/global-skills/publish-app/SKILL.md +1 -1
  55. package/dist/global-skills/publish-extension/SKILL.md +1 -1
  56. package/dist/global-skills/reset-password/SKILL.md +1 -1
  57. package/dist/global-skills/save-data/SKILL.md +1 -1
  58. package/dist/global-skills/setup-email/SKILL.md +1 -1
  59. package/dist/global-skills/setup-payments/SKILL.md +1 -1
  60. package/dist/global-skills/setup-sms/SKILL.md +1 -1
  61. package/dist/global-skills/sign-in-with-email-link/SKILL.md +1 -1
  62. package/dist/global-skills/sign-in-with-google/SKILL.md +1 -1
  63. package/dist/global-skills/sign-in-with-phone/SKILL.md +1 -1
  64. package/dist/global-skills/stripe-best-practices/SKILL.md +6 -11
  65. package/dist/global-skills/stripe-best-practices/references/billing.md +0 -5
  66. package/dist/global-skills/stripe-best-practices/references/payments.md +2 -4
  67. package/dist/global-skills/stripe-best-practices/references/tax.md +8 -78
  68. package/dist/global-skills/track-errors/SKILL.md +1 -1
  69. package/dist/global-skills/update-kit/SKILL.md +1 -1
  70. package/dist/global-skills/wire-auth/SKILL.md +1 -1
  71. package/dist/global-skills/wire-database/SKILL.md +1 -1
  72. package/dist/global-skills/wire-email/SKILL.md +1 -1
  73. package/dist/global-skills/wire-payments/SKILL.md +1 -1
  74. package/package.json +8 -8
  75. package/dist/global-skills/email-best-practices/.github/workflows/sync-skills.yml +0 -30
  76. package/dist/global-skills/email-best-practices/README.md +0 -63
  77. package/dist/global-skills/email-best-practices/references/accessibility.md +0 -189
  78. package/dist/global-skills/email-best-practices/references/compliance.md +0 -125
  79. package/dist/global-skills/email-best-practices/references/deliverability.md +0 -121
  80. package/dist/global-skills/email-best-practices/references/email-capture.md +0 -129
  81. package/dist/global-skills/email-best-practices/references/email-types.md +0 -173
  82. package/dist/global-skills/email-best-practices/references/list-management.md +0 -157
  83. package/dist/global-skills/email-best-practices/references/marketing-emails.md +0 -115
  84. package/dist/global-skills/email-best-practices/references/sending-reliability.md +0 -155
  85. package/dist/global-skills/email-best-practices/references/transactional-email-catalog.md +0 -418
  86. package/dist/global-skills/email-best-practices/references/transactional-emails.md +0 -92
  87. package/dist/global-skills/email-best-practices/references/webhooks-events.md +0 -167
  88. package/dist/global-skills/email-best-practices/tests/README.md +0 -35
  89. package/dist/global-skills/email-best-practices/tests/scenarios/01-spam-deliverability.md +0 -46
  90. package/dist/global-skills/email-best-practices/tests/scenarios/02-multi-region-compliance.md +0 -48
  91. package/dist/global-skills/email-best-practices/tests/scenarios/03-retry-idempotency.md +0 -36
  92. package/dist/global-skills/email-best-practices/tests/scenarios/04-webhook-bounce-handling.md +0 -52
  93. package/dist/global-skills/email-best-practices/tests/scenarios/05-new-saas-email-plan.md +0 -51
  94. package/dist/global-skills/neon-postgres/references/neon-sdk.md +0 -262
@@ -1,164 +1,711 @@
1
1
  # Serverless Troubleshooting Reference
2
2
 
3
- Error cause fix, focused on non-obvious gotchas and exact CLI commands. The five most common fixes are first.
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
+ ---
4
19
 
5
20
  ## Quick fixes
6
21
 
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.
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.
12
37
 
13
38
  ---
14
39
 
15
- ## Lambda errors (gotchas)
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
+ ```
16
141
 
17
142
  ### RecursiveInvocationException
18
143
 
19
- A function writes to a resource that re-triggers it (Lambda halts after ~16 loops).
144
+ **Error:** `RecursiveInvocationException: Recursive invocation detected`
145
+ **Cause:** Function writes to a resource that triggers itself again (~16 invocations before halt).
20
146
 
21
147
  ```bash
22
- # Emergency stop:
148
+ # Emergency stop
23
149
  aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 0
24
- # Fix: separate input/output buckets, or prefix filters in the trigger config
150
+ # Fix: use separate input/output buckets or prefix filters in trigger config
25
151
  ```
26
152
 
27
- ### SnapStart errors
153
+ ### SnapStart Errors
28
154
 
29
- `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException` — init threw, or it uses non-snapshottable resources (open network connections).
155
+ **Error:** `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException`
156
+ **Cause:** SnapStart failed during snapshot — init threw exception or uses non-snapshottable resources (e.g., open network connections).
30
157
 
31
158
  ```bash
32
159
  aws lambda get-function --function-name my-func --query 'Configuration.SnapStart'
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
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
36
163
  ```
37
164
 
38
165
  ### Sandbox.Timedout
39
166
 
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`.
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
+ ```
41
174
 
42
175
  ### ENILimitReachedException
43
176
 
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`).
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.
45
179
 
46
180
  ```bash
47
181
  aws service-quotas request-service-quota-increase --service-code vpc --quota-code L-DF5E4CA3 --desired-value 10000
48
- # Consolidate functions onto the same subnet + security group combinations
182
+ # Consolidate functions to use same subnet + security group combinations
49
183
  ```
50
184
 
51
- ### TooManyRequestsException / throttling
185
+ ### InvalidZipFileException
186
+
187
+ **Error:** `InvalidZipFileException: Could not unzip uploaded file.`
188
+ **Cause:** Invalid ZIP or handler nested in subdirectory instead of at root.
52
189
 
53
190
  ```bash
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
191
+ unzip -t deployment.zip # verify integrity
192
+ cd my-folder && zip -r ../deployment.zip . && cd .. # files at root, not nested
57
193
  ```
58
194
 
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
-
61
195
  ### CodeStorageExceededException
62
196
 
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`).
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
+ ```
64
205
 
65
206
  ---
66
207
 
67
- ## API Gateway errors (gotchas)
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
+ ```
68
273
 
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 |
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
+ ```
76
305
 
77
306
  ---
78
307
 
79
- ## Step Functions errors
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
80
321
 
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 |
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
+ ```
88
356
 
89
357
  ---
90
358
 
91
- ## SAM/CDK errors
359
+ ## SAM/CDK Error Lookup
92
360
 
93
- ### Stale build cache
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.
94
365
 
95
366
  ```bash
96
- sam build --no-cached # correct flag there is NO --clear-cache
97
- rm -rf .aws-sam/cache # or delete the cache directory
367
+ sam build --no-cached # Force clean build (correct flag)
368
+ rm -rf .aws-sam/cache # Or manually delete cache directory
98
369
  ```
99
370
 
100
371
  ### PythonPipBuilder:ResolveDependencies
101
372
 
102
- Version conflicts or missing native libs: `sam build --use-container --no-cached`; use binary wheels (`psycopg2-binary`).
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'
103
392
 
104
- ### CDK NodejsFunction: `Cannot find module 'esbuild'`
393
+ **Error:** `Cannot find module 'esbuild'`
394
+ **Cause:** CDK `NodejsFunction` needs esbuild for bundling.
395
+
396
+ ```bash
397
+ npm install --save-dev esbuild
398
+ ```
105
399
 
106
- `npm install --save-dev esbuild`.
400
+ ### CREATE_FAILED
107
401
 
108
- ### CREATE_FAILED / UPDATE_ROLLBACK_FAILED
402
+ **Error:** `CREATE_FAILED: AWS::Lambda::Function`
403
+ **Cause:** Invalid runtime, missing S3 code, role not ready, or package too large.
109
404
 
110
405
  ```bash
111
406
  aws cloudformation describe-stack-events --stack-name my-stack \
112
407
  --query "StackEvents[?ResourceStatus=='CREATE_FAILED'].[LogicalResourceId,ResourceStatusReason]" --output table
113
- # Rollback also failed (resource manually deleted / perms changed):
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
114
417
  aws cloudformation continue-update-rollback --stack-name my-stack --resources-to-skip MyFunction
115
418
  ```
116
419
 
117
- ### Circular dependency
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
118
430
 
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.
431
+ **Error:** `This stack uses assets, so the toolkit stack must be deployed`
432
+ **Cause:** Target account/region not bootstrapped.
120
433
 
121
- ### Other quick ones
434
+ ```bash
435
+ cdk bootstrap aws://123456789012/us-east-1
436
+ ```
122
437
 
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`.
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
+ ```
126
462
 
127
463
  ---
128
464
 
129
- ## Diagnostics
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)
130
590
 
131
- For systematic timeout investigation (config → logs → metrics → VPC → cold start → memory → downstream), use the **debugging-lambda-timeouts** skill (see SKILL.md routing).
591
+ ```
592
+ filter @type = "REPORT" | stats avg(@maxMemoryUsed/1e6) as avgMemMB by bin(5m) | sort bin asc
593
+ ```
132
594
 
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:
595
+ ### Latency Percentiles
134
596
 
135
597
  ```
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)
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
139
603
 
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
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
+ ```
143
609
 
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)
610
+ ### API Gateway 5xx
147
611
 
148
- # API Gateway 5xx (access log group)
612
+ ```
149
613
  filter status >= 500 | stats count() as errors by status, path, httpMethod | sort errors desc
150
614
  ```
151
615
 
152
- ### Memory vCPU (for OOM / CPU tuning)
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
153
623
 
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 |
624
+ ```
625
+ filter @message like /Rate Exceeded|TooManyRequestsException|Throttl/
626
+ | fields @timestamp, @requestId, @message | sort @timestamp desc | limit 50
627
+ ```
161
628
 
162
- ### X-Ray
629
+ ### Billed Duration
163
630
 
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).
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
+ ```