Summary
This release graduates the Auth utility out of alpha and adds SigV4 request signing to it and closes the nine Idempotency bugs from our audit.
The community carried this one too: sixteen community PRs from twelve people, nine of them contributing for the first time. Welcome @lechakrawarthy, @coughlmao, @sumedh-aerram, @Neeraj111010, @AP24110011695, @haeganm, @CJstate, @krishbuilds01 and @dhairyakhandelwal880-dotcom. Thanks to @soujasK, @Manishram-ai and @anishmehta24 for coming back, @anishmehta24 for the third release in a row.
Reminder: we stop supporting Python 3.10 on February 1, 2027. Details in #8735.
Auth is GA, and auth_alpha is gone
We moved the Auth utility from aws_lambda_powertools.utilities.auth_alpha to aws_lambda_powertools.utilities.auth. Nothing else changed: JWTVerifier, OAuth2Client, the Event Handler middleware, the API Gateway authorizer and the jwt extra work exactly as in 3.40.0. The alpha label said the API could change before GA; the API held, the import path did not, and we removed the old namespace on purpose so nobody keeps shipping code against it. If you import from auth_alpha, update one line:
from aws_lambda_powertools.utilities.auth import JWTVerifier, OAuth2ClientSigV4 request signing
You can now sign HTTP requests to IAM-protected AWS endpoints: API Gateway with IAM auth, Lambda Function URLs, AppSync, OpenSearch, S3. SigV4Signer uses the botocore the Lambda runtime already ships, so there is nothing to install. Call sign() and send the result with any HTTP client, or pass requests_auth() or httpx_auth() as auth= and let the client sign every request on the way out. Use service="s3" for S3 and the signer applies the S3 canonical rules. For multi-region signatures, SigV4aSigner lives behind the auth-sigv4a extra.
import requests
from aws_lambda_powertools.utilities.auth import SigV4Signer
api = SigV4Signer(service="execute-api") # region and credentials come from the Lambda environment
response = requests.post(url, json=payload, auth=api.requests_auth())This follows the design Powertools for TypeScript shipped this year and closes #2493, open since 2023. Thank you @stephenbawks for the original PR back then.
Environment variables no longer crash on bad values
Set POWERTOOLS_DEV, POWERTOOLS_DEBUG, POWERTOOLS_METRICS_DISABLED, POWERTOOLS_CIRCUIT_BREAKER_DISABLED, POWERTOOLS_IDEMPOTENCY_DISABLED or POWERTOOLS_PARAMETERS_MAX_AGE to an empty string or to maybe and every invocation used to die with ValueError. They now emit a PowertoolsUserWarning and fall back to the default, all through one resolver, and an explicit argument always wins. Thank you @krishbuilds01, @AP24110011695 and @lechakrawarthy.
Idempotency
We fixed all nine items from the audit in #8603:
- When your function returns something the serializer or
json.dumpscannot handle, we still raiseIdempotencyPersistenceLayerError, but we now clear the in-progress record first. The next call runs the function instead of hittingIdempotencyAlreadyInProgressErrorfor an hour. PydanticSerializerandDataclassSerializerresolve return annotations underfrom __future__ import annotations. A container such aslist[Model]raisesIdempotencyModelTypeErrorinstead of a rawTypeError.- With a DynamoDB composite key,
DataRecord.idempotency_keycarries the operation's key, so the local cache and your response hooks see the right value instead of the static partition key. - Payloads with
set,frozensetorbyteshash deterministically. - Redis: we retry when the record vanishes between
SET NXandGETinstead of failing the invocation, and the orphan lock TTL followsexpires_after_secondsinstead of always being ten seconds. - Reuse one persistence layer with a different
IdempotencyConfigand we warn you; the first config still wins. - The
IdempotencyConfigdocstring now sayslocal_cache_max_itemsdefaults to 256, like the code does.
Thank you @sumedh-aerram, @Neeraj111010, @coughlmao, @CJstate, @lechakrawarthy and @soujasK.
Metrics
add_metricnow skips aNaNor infinite value with aPowertoolsUserWarning. Before,json.dumpswrote it bare into the EMF line and CloudWatch dropped every metric in that flush without a word.single_metricalso stops printing anullline when thewithbody raises. Thank you @anishmehta24.POWERTOOLS_METRICS_DISABLEDnow silencessingle_metric, the cold start metric, the auto-flush at 100 metrics and the Datadog provider, not onlyflush_metrics().POWERTOOLS_DEV=truedisables metrics on every path too. Thank you @soujasK.
Logger
thread_safe_remove_keys now copies the thread-local dict before removing a key, so a remove inside an asyncio task or an asyncio.to_thread worker stays in that task instead of wiping the key for the caller and everyone else. Thank you @haeganm.
Parser, Event Handler and Data Classes
- The Cognito trigger models accept the events Cognito really sends:
CUSTOM_CHALLENGEin auth challenge sessions,answerCorrectasnull, and every documentedtriggerSourcefor pre sign-up, post confirmation and the custom senders. We checked them against a live user pool. - The SES models accept a
RequestResponseaction and emails withoutToorSubject; the data class returnsNonefor headers the email does not carry. APIGatewayProxyEventModelkeeps the Lambda authorizer'sprincipalId,integrationLatencyand context keys.SQSRecord.queue_urlbuilds the right DNS suffix for China, the ISO partitions andaws-eusc.Path(alias=...)emits the alias in the OpenAPI schema when it matches the route template, a regression we introduced in 3.39.0.
Thank you @Manishram-ai, @dhairyakhandelwal880-dotcom and @anishmehta24 for the reports and the fixes.
Changes
- docs(idempotency): fix local_cache_max_items default in IdempotencyConfig docstring (#8731) by @lechakrawarthy
- fix(idempotency): treat empty or unparsable POWERTOOLS_IDEMPOTENCY_DISABLED as not disabled (#8734) by @lechakrawarthy
- fix(metrics): respect POWERTOOLS_METRICS_DISABLED in every emission path (#8668) by @soujasK
- fix(idempotency): compute the Redis orphan lock timeout from the configured expiry (#8779) by @CJstate
- chore(ci): regenerate the agent skill references in the release instead of after every docs merge (#8811) by @leandrodamascena
- fix(idempotency): retry Redis inconsistent state errors (#8736) by @coughlmao
- fix(idempotency): add deterministic support for set, frozenset, and bytes types (#8741) by @Neeraj111010
- fix(parameters): ignore malformed POWERTOOLS_PARAMETERS_MAX_AGE instead of crashing (#8757) by @AP24110011695
- fix(logger): empty or unparsable POWERTOOLS_DEV no longer crashes Logger (#8783) by @krishbuilds01
πNew features and non-breaking changes
- feat(auth): add SigV4 and SigV4a request signing (#8820) by @leandrodamascena
- feat(auth): graduate the Auth utility from auth_alpha to auth (#8818) by @leandrodamascena
π Documentation updates
- feat(auth): add SigV4 and SigV4a request signing (#8820) by @leandrodamascena
- feat(auth): graduate the Auth utility from auth_alpha to auth (#8818) by @leandrodamascena
- fix(metrics): skip non-finite metric values with a warning (#8797) by @anishmehta24
- fix(idempotency): warn when a persistence layer is reused with a different config (#8664) by @soujasK
- fix(idempotency): clear the in progress record when the response can't be serialized (#8740) by @sumedh-aerram
- fix(idempotency): resolve postponed return annotations for serializer classes (#8738) by @sumedh-aerram
- fix(idempotency): use the record key for DynamoDB composite items (#8739) by @sumedh-aerram
- chore(docs): regenerate the agent skill references after merge instead of in every PR (#8807) by @leandrodamascena
π Bug and hot fixes
- fix(logger): copy thread-local keys in thread_safe_remove_keys (#8772) by @haeganm
- fix(parser): keep Lambda authorizer context in APIGatewayProxyEventModel (#8813) by @Manishram-ai
- fix(data_classes): resolve correct SQS queue URL for China and other AWS partitions (#8799) (#8814) by @dhairyakhandelwal880-dotcom
- fix(parser): accept SES events without common headers or invocation type (#8768) by @Manishram-ai
- fix(parser): accept real Cognito trigger events (#8762) by @Manishram-ai
- fix(event_handler): emit the Path alias in the OpenAPI schema when it matches the route template (#8812) by @leandrodamascena
π§ Maintenance
- feat(auth): add SigV4 and SigV4a request signing (#8820) by @leandrodamascena
- feat(auth): graduate the Auth utility from auth_alpha to auth (#8818) by @leandrodamascena
- chore(deps): bump opentelemetry-api from 1.45.1 to 1.45.2 (#8804) by @dependabot[bot]
This release was made possible by the following contributors:
@anishmehta24, @AP24110011695, @CJstate, @coughlmao, @dhairyakhandelwal880-dotcom, @haeganm, @krishbuilds01, @leandrodamascena, @lechakrawarthy, @Manishram-ai, @Neeraj111010, @soujasK, @sumedh-aerram and @dependabot[bot]