AWS powertools documentation change
Summary
Added documentation for 'throwOnMissing' parameter handling, updated navigation links, and modified date
Security assessment
The 'throwOnMissing' feature improves error handling for missing configurations but doesn't fix vulnerabilities or document security features. The type casting change is unrelated to security.
Diff
diff --git a/powertools/typescript/latest/features/parameters.md b/powertools/typescript/latest/features/parameters.md index 42a4fd831..6293cd08d 100644 --- a//powertools/typescript/latest/features/parameters.md +++ b//powertools/typescript/latest/features/parameters.md @@ -61,0 +62 @@ Event Handler + * Throwing on missing values @@ -81,0 +83 @@ Event Handler + * [ Data Masking ](../data-masking/) @@ -82,0 +85 @@ Event Handler + * [ Signer ](../signer/) @@ -117,0 +121 @@ Table of contents + * Throwing on missing values @@ -642,0 +647,54 @@ Forcefully fetching the latest parameter whether TTL has expired or not +### Throwing on missing values¶ + +By default, fetching a value that does not exist returns `undefined` for providers whose backend signals absence with an empty response (e.g. DynamoDB and AppConfig), while the SSM and Secrets Manager providers throw a `GetParameterError` because their underlying APIs raise a not-found error. + +If you'd rather fail fast with a dedicated, typed error in all cases, set the `throwOnMissing` option. When enabled, a missing value throws a `ParameterNotFoundError` and the return type is narrowed to exclude `undefined`, so you no longer need to guard against it. + +Throwing a ParameterNotFoundError when a value is missing +--- + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + +| + + + import { ParameterNotFoundError } from '@aws-lambda-powertools/parameters/errors'; + import { getParameter } from '@aws-lambda-powertools/parameters/ssm'; + + export const handler = async (): Promise<void> => { + try { + // The return type is narrowed to `string` (no longer `string | undefined`) + const parameter = await getParameter('/my/parameter', { + throwOnMissing: true, + }); + console.log(parameter.toUpperCase()); + } catch (error) { + if (error instanceof ParameterNotFoundError) { + console.error('The parameter does not exist in the store'); + } + throw error; + } + }; + + +Note + +`ParameterNotFoundError` extends `GetParameterError`, so existing `catch` blocks that check for `GetParameterError` keep working. Use `ParameterNotFoundError` when you want to handle a genuinely missing value separately from other retrieval failures (e.g. network or permission errors). + @@ -1220,0 +1279,2 @@ Provider usageProvider implementationProvider types + 105 + 106 @@ -1311 +1371,3 @@ Provider usageProvider implementationProvider types - const response = await res.json(); + const response = (await res.json()) as { + data: { data: Record<string, unknown> }; + }; @@ -2364 +2426 @@ handler.test.ts -2026-05-27 +2026-07-10