Skip to content

v3.30.0

Latest

Choose a tag to compare

@github-actions github-actions released this 25 Jun 15:45
· 6 commits to refs/heads/develop since this release

Summary

This release adds a custom serializer option to the BedrockAgentResolver, plus documentation improvements and bug fixes across the Event Handler.

A huge thanks to @kimnamu, @Avinm and @hirenkumar-n-dholariya for their contributions!

Custom serializer on BedrockAgentResolver

Docs

You can now pass your own serializer to BedrockAgentResolver, the same way the other resolvers already allow. This lets you control exactly how responses are serialized to JSON, for example to handle custom types or tune the output format.

import json
from decimal import Decimal

from aws_lambda_powertools.event_handler import BedrockAgentResolver
from aws_lambda_powertools.utilities.typing import LambdaContext


def custom_serializer(obj: dict) -> str:
    return json.dumps(obj, default=str)


app = BedrockAgentResolver(serializer=custom_serializer)


@app.get("/price", description="Returns the current price")
def get_price() -> dict:
    return {"price": Decimal("9.99")}


def lambda_handler(event: dict, context: LambdaContext):
    return app.resolve(event, context)

Changes

  • feat(event_handler): allow custom serializer on BedrockAgentResolver (#8271) by @kimnamu
  • fix(event-handler): handle CORS preflight OPTIONS in HttpResolverLocal (#8268) by @Avinm
  • fix(event-handler): fix ruff lint violations in event_handler module (#8208) by @hirenkumar-n-dholariya

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@Avinm, @Sujit-1509, @dependabot[bot], @derdelean, @github-actions[bot], @hirenkumar-n-dholariya, @kimnamu, @leandrodamascena, dependabot[bot] and github-actions[bot]