Skip to content

Commit 035757a

Browse files
authored
Merge branch 'main' into parser/docs-test-section
2 parents c3cd864 + aa52802 commit 035757a

38 files changed

+785
-173
lines changed

.github/workflows/ossf_scorecard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# repo_token: ${{ secrets.SCORECARD_TOKEN }} # read-only fine-grained token to read branch protection settings
3636

3737
- name: "Upload results"
38-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
38+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
3939
with:
4040
name: SARIF file
4141
path: results.sarif

.github/workflows/publish_layer.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Zip output
4646
run: zip -r cdk.out.zip layers/cdk.out
4747
- name: Archive CDK artifacts
48-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
48+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
4949
with:
5050
name: cdk-layer-artifact
5151
path: cdk.out.zip
@@ -97,7 +97,7 @@ jobs:
9797
with:
9898
ref: ${{ github.sha }}
9999
- name: Download CDK layer artifacts
100-
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
100+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
101101
with:
102102
path: cdk-layer-stack
103103
pattern: cdk-layer-stack-* # merge all Layer artifacts created per region earlier (reusable_deploy_layer_stack.yml; step "Save Layer ARN artifact")

.github/workflows/record_pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
script: |
5454
const script = require('.github/scripts/save_pr_details.js')
5555
await script({github, context, core})
56-
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
56+
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
5757
with:
5858
name: pr
5959
path: pr.txt

.github/workflows/reusable_deploy_layer_stack.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
- name: Setup dependencies
7979
uses: ./.github/actions/cached-node-modules
8080
- name: Download artifact
81-
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
81+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
8282
with:
8383
name: ${{ inputs.artifact-name }}
8484
- name: Unzip artifact
@@ -93,7 +93,7 @@ jobs:
9393
cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt
9494
- name: Save Layer ARN artifact
9595
if: ${{ inputs.stage == 'PROD' }}
96-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
96+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
9797
with:
9898
name: cdk-layer-stack-${{ matrix.region }}
9999
path: ./cdk-layer-stack/* # NOTE: upload-artifact does not inherit working-directory setting.

.github/workflows/reusable_publish_docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
run: |
9797
cp -r api site/
9898
- name: Create Artifact (Site)
99-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
99+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
100100
with:
101101
name: site
102102
path: site

docs/core/logger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ This functionality will include the following keys in your structured logs:
111111
=== "Middy Middleware"
112112

113113
!!! tip "A note about Middy"
114-
We guarantee support only for Middy.js `v4.x`, that you can install it by running `npm i @middy/core@~4`.
114+
We guarantee support for both Middy.js `v4.x` & `v5.x` with the latter being available only if you are using ES modules.
115115
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.
116116

117117
```typescript hl_lines="2 14"

docs/core/metrics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ You can add default dimensions to your metrics by passing them as parameters in
199199
=== "Middy middleware"
200200

201201
!!! tip "A note about Middy"
202-
Currently we support up to Middy `v4.x` that you can install it by running `npm i @middy/core@~4`.
202+
We guarantee support for both Middy.js `v4.x` & `v5.x` with the latter being available only if you are using ES modules.
203203
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.
204204

205205
```typescript hl_lines="24-26"

docs/core/tracer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
154154
=== "Middy Middleware"
155155

156156
!!! tip "A note about Middy"
157-
We guarantee support only for Middy.js `v4.x`, that you can install it by running `npm i @middy/core@~4`.
157+
We guarantee support for both Middy.js `v4.x` & `v5.x` with the latter being available only if you are using ES modules.
158158
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.
159159

160160
```typescript hl_lines="2 15 17"

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{aws::region}:094274105
299299

300300
Many of the utilities provided by Powertools for AWS Lambda (TypeScript) can be used with different programming paradigms:
301301

302-
- **Middy** middleware. It is the best choice if your existing code base relies on the [Middy 4.x](https://middy.js.org/docs/) middleware engine. Powertools for AWS Lambda (TypeScript) offers compatible Middy middleware to make this integration seamless.
302+
- **Middy** middleware. It is the best choice if your existing code base relies on the [Middy.js](https://middy.js.org/docs/) middleware engine. Powertools for AWS Lambda (TypeScript) offers compatible Middy middleware to make this integration seamless.
303303
- **Method decorator**. Use [TypeScript method decorators](https://www.typescriptlang.org/docs/handbook/decorators.html#method-decorators) if you prefer writing your business logic using [TypeScript Classes](https://www.typescriptlang.org/docs/handbook/classes.html). If you aren’t using Classes, this requires the most significant refactoring.
304304
- **Manually**. It provides the most granular control. It’s the most verbose approach, with the added benefit of no additional dependency and no refactoring to TypeScript Classes.
305305

docs/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ babel==2.14.0 \
88
--hash=sha256:6919867db036398ba21eb5c7a0f6b28ab8cbc3ae7a73a44ebe34ae74a4e7d363 \
99
--hash=sha256:efb1a25b7118e67ce3a259bed20545c29cb68be8ad2c784c83689981b7a57287
1010
# via mkdocs-material
11-
certifi==2023.11.17 \
12-
--hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \
13-
--hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
11+
certifi==2024.7.4 \
12+
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
13+
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
1414
# via requests
1515
charset-normalizer==3.3.2 \
1616
--hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \

docs/utilities/batch.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ All records in the batch will be passed to this handler for processing, even if
261261

262262
* **All records successfully processed**. We will return an empty list of item failures `{'batchItemFailures': []}`
263263
* **Partial success with some exceptions**. We will return a list of all item IDs/sequence numbers that failed processing
264-
* **All records failed to be processed**. We will raise `BatchProcessingError` exception with a list of all exceptions raised when processing
264+
* **All records failed to be processed**. We will throw a `FullBatchFailureError` error with a list of all the errors thrown while processing unless `throwOnFullBatchFailure` is disabled.
265265

266266
The following sequence diagrams explain how each Batch processor behaves under different scenarios.
267267

@@ -450,6 +450,18 @@ We can automatically inject the [Lambda context](https://docs.aws.amazon.com/lam
450450
--8<-- "examples/snippets/batch/accessLambdaContext.ts"
451451
```
452452

453+
### Working with full batch failures
454+
455+
By default, the `BatchProcessor` will throw a `FullBatchFailureError` if all records in the batch fail to process, we do this to reflect the failure in your operational metrics.
456+
457+
When working with functions that handle batches with a small number of records, or when you use errors as a flow control mechanism, this behavior might not be desirable as your function might generate an unnaturally high number of errors. When this happens, the [Lambda service will scale down the concurrency of your function](https://docs.aws.amazon.com/lambda/latest/dg/services-sqs-errorhandling.html#services-sqs-backoff-strategy){target="_blank"}, potentially impacting performance.
458+
459+
For these scenarios, you can set the `throwOnFullBatchFailure` option to `false` when calling.
460+
461+
```typescript hl_lines="17"
462+
--8<-- "examples/snippets/batch/noThrowOnFullBatchFailure.ts"
463+
```
464+
453465
### Extending BatchProcessor
454466

455467
You might want to bring custom logic to the existing `BatchProcessor` to slightly override how we handle successes and failures.

docs/utilities/idempotency.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ The configuration options for the `@idempotent` decorator are the same as the on
189189
### MakeHandlerIdempotent Middy middleware
190190

191191
!!! tip "A note about Middy"
192-
Currently we support Middy up to `v4.x` that you can install it by running `npm i @middy/core@~4`.
192+
We guarantee support for both Middy.js `v4.x` & `v5.x` with the latter being available only if you are using ES modules.
193193
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.
194194

195195
If you are using [Middy.js](https://middy.js.org){target="_blank"} as your middleware engine, you can use the `makeHandlerIdempotent` middleware to make your Lambda handler idempotent.

examples/app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
"@aws-lambda-powertools/metrics": "^2.3.0",
5252
"@aws-lambda-powertools/parameters": "^2.3.0",
5353
"@aws-lambda-powertools/tracer": "^2.3.0",
54-
"@aws-sdk/client-ssm": "^3.609.0",
55-
"@aws-sdk/lib-dynamodb": "^3.609.0",
54+
"@aws-sdk/client-ssm": "^3.613.0",
55+
"@aws-sdk/lib-dynamodb": "^3.613.0",
5656
"@middy/core": "^4.7.0",
5757
"@types/aws-lambda": "^8.10.140",
5858
"@types/jest": "^29.5.12",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
BatchProcessor,
3+
EventType,
4+
processPartialResponse,
5+
} from '@aws-lambda-powertools/batch';
6+
import type { SQSHandler, SQSRecord } from 'aws-lambda';
7+
8+
const processor = new BatchProcessor(EventType.SQS);
9+
10+
const recordHandler = async (_record: SQSRecord): Promise<void> => {
11+
// Process the record
12+
};
13+
14+
export const handler: SQSHandler = async (event, context) =>
15+
processPartialResponse(event, recordHandler, processor, {
16+
context,
17+
throwOnFullBatchFailure: false,
18+
});

examples/snippets/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"@aws-lambda-powertools/parameters": "^2.3.0",
3838
"@aws-lambda-powertools/parser": "^2.3.0",
3939
"@aws-lambda-powertools/tracer": "^2.3.0",
40-
"@aws-sdk/client-appconfigdata": "^3.609.0",
41-
"@aws-sdk/client-dynamodb": "^3.609.0",
42-
"@aws-sdk/client-secrets-manager": "^3.609.0",
43-
"@aws-sdk/client-ssm": "^3.609.0",
44-
"@aws-sdk/util-dynamodb": "^3.609.0",
40+
"@aws-sdk/client-appconfigdata": "^3.613.0",
41+
"@aws-sdk/client-dynamodb": "^3.613.0",
42+
"@aws-sdk/client-secrets-manager": "^3.613.0",
43+
"@aws-sdk/client-ssm": "^3.613.0",
44+
"@aws-sdk/util-dynamodb": "^3.613.0",
4545
"@middy/core": "^4.7.0",
4646
"aws-sdk": "^2.1652.0",
4747
"aws-sdk-client-mock": "^4.0.1",

0 commit comments

Comments
 (0)