Summary
We’ve listened to your feedback and starting from this release of Parser we support only Zod v4 for all our built-in schemas and envelopes. Additionally the utility got a power up and it now supports schemas written using Standard Schema 🔥.
We’ve also fixed a bug in Tracer that prevented requests made via proxies to be traced correctly and another bug in Metrics that caused dimension sets to be added correctly to the metrics data object..
🌟 Congratulations to @chetan9518, @sdangol, and @matteofigus for their first PRs merged in the project 🎉
Using Parser with Standard Schema
You can now use schemas written using Valibot or other Standard Schema-compatible parsing library to parse incoming events using the parser
Middy.js middleware or TypeScript class method decorator. This is useful if your codebase is already relying on one of these libraries or you want to have full control over the bundle size.
Note that our built-in schemas and envelopes are still defined only using Zod. If you would like us to support other libraries like Valibot please open an issue and we will consider it based on the community's feedback.
If you are using Zod v3 and need more time to migrate, you can continue using Parser v2.23.0 as long as needed.
import { Logger } from '@aws-lambda-powertools/logger';
import { parser } from '@aws-lambda-powertools/parser/middleware';
import middy from '@middy/core';
import {
array,
number,
object,
optional,
pipe,
string,
toMinValue,
} from 'valibot';
const logger = new Logger();
const orderSchema = object({
id: pipe(number(), toMinValue(0)),
description: string(),
items: array(
object({
id: pipe(number(), toMinValue(0)),
quantity: pipe(number(), toMinValue(1)),
description: string(),
})
),
optionalField: optional(string()),
});
export const handler = middy()
.use(parser({ schema: orderSchema }))
.handler(async (event): Promise<void> => {
for (const item of event.items) {
logger.info('Processing item', { item });
}
});
Tracing requests using a proxy
You can now correctly trace outbound requests made via proxies. Tracer will detect the CONNECT request made to the proxy and intelligently exclude it from the trace data, leaving only the segment for the main request to avoid creating noise in your traces.
import { Tracer } from "@aws-lambda-powertools/tracer";
import { getSecret } from "@aws-lambda-powertools/parameters/secrets";
import { captureLambdaHandler } from "@aws-lambda-powertools/tracer/middleware";
import middy from "@middy/core";
import { ProxyAgent } from "undici";
const tracer = new Tracer({
serviceName: "tracerproxy",
});
const client = new ProxyAgent({
uri: "http://proxy:8080",
token: await getSecret('/dev/proxy-token'),
});
export const handler = middy()
.use(captureLambdaHandler(tracer))
.handler(async () => {
try {
const res = await fetch("https://foo.com", {
dispatcher: client,
signal: AbortSignal.timeout(2000),
});
console.debug("Response status:", res.status);
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
} catch (error) {
console.error("Error fetching URL:", error);
if (error instanceof HttpError) {
return {
statusCode: error.code,
};
}
return {
statusCode: 500,
};
}
return {
statusCode: 200,
};
});
Adding dimension sets to metrics
You can create separate dimension sets for your metrics using the addDimensions()
method. This allows you to group metrics by different dimension combinations.
Starting from this release, when you use this method, we’ll create a new dimension set rather than adding to the existing dimensions - the previous behavior was incorrect and didn’t allow you to track the same metric across different dimension combinations.
import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
const metrics = new Metrics({
namespace: 'serverlessAirline',
serviceName: 'orders',
});
export const handler = async (
_event: unknown,
_context: unknown
): Promise<void> => {
// Add a single dimension
metrics.addDimension('environment', 'prod');
// Add a new dimension set
metrics.addDimensions({
dimension1: '1',
dimension2: '2',
});
// Add another dimension set
metrics.addDimensions({
region: 'us-east-1',
category: 'books',
});
// Add metrics
metrics.addMetric('successfulBooking', MetricUnit.Count, 1);
metrics.publishStoredMetrics();
};
Changes
- fix(parser): Removed the nullable type from the md5OfMessageAttributes in SqsRecordSchema (#4165) by @sdangol
- chore(parser): remove deprecated parser type (#4154) by @dreamorosi
- refactor(metrics): optimize
addDimensions
method to avoid O(n²) complexity (#4156) by @dreamorosi - chore: fix typo in partitioned layers workflow (#4126) by @dreamorosi
🌟New features and non-breaking changes
- feat(event-handler): add base router class (#3972) by @dreamorosi
📜 Documentation updates
- chore: bump to 2.24.0 (#4172) by @dreamorosi
- chore(deps): bump @types/node from 24.0.12 to 24.0.13 (#4167) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.5 to 0.25.6 (#4166) by @dependabot[bot]
- feat(parser): support Standard Schema and upgrade to Zod v4 (#4164) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4159) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.10 to 24.0.12 (#4157) by @dependabot[bot]
- chore(batch): exclude deprecated code from coverage (#4152) by @dreamorosi
- docs(idempotency): simplify snippets (#4150) by @dreamorosi
- fix(tracer): skip tracing CONNECT requests (#4148) by @dreamorosi
- chore(deps): bump aws-cdk-lib from 2.203.1 to 2.204.0 in the aws-cdk group across 1 directory (#4143) by @dependabot[bot]
- chore: bump biome formatter to next major & reformat (#4145) by @dreamorosi
- docs: update roadmap with completed features and Discord badge (#4133) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4129) by @dependabot[bot]
- fix(metrics): addDimensions() documentation and tests (#3964) by @matteofigus
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
🐛 Bug and hot fixes
- fix(metrics): addDimensions() documentation and tests (#3964) by @matteofigus
🔧 Maintenance
- chore: bump to 2.24.0 (#4172) by @dreamorosi
- chore(deps): bump @types/node from 24.0.12 to 24.0.13 (#4167) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.5 to 0.25.6 (#4166) by @dependabot[bot]
- feat(parser): support Standard Schema and upgrade to Zod v4 (#4164) by @dreamorosi
- chore(deps-dev): bump @redis/client from 5.5.6 to 5.6.0 (#4162) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4159) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
0d29e5f
toeac37fb
in /.devcontainer (#4161) by @dependabot[bot] - chore(deps-dev): bump zod from 3.25.67 to 3.25.76 (#4158) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.10 to 24.0.12 (#4157) by @dependabot[bot]
- refactor(tracer): replace class-based env access with functional helpers (#4146) by @chetan9518
- chore(deps): bump aws-cdk-lib from 2.203.1 to 2.204.0 in the aws-cdk group across 1 directory (#4143) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 1.9.4 to 2.1.0 (#4147) by @dependabot[bot]
- chore: bump biome formatter to next major & reformat (#4145) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4129) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
- chore(deps-dev): bump @aws-sdk/client-cloudwatch from 3.840.0 to 3.841.0 in the aws-sdk-v3 group across 1 directory (#4117) by @dependabot[bot]
This release was made possible by the following contributors:
@chetan9518, @dependabot[bot], @dreamorosi, @github-actions[bot], @matteofigus, @sdangol, dependabot[bot] and github-actions[bot]