Closed
Description
Expected Behavior
This is probably a follow up to #1481
When the @idempotent
decorator is used with other powertools decorators such as the @tracer.captureLambdaHandler()
decorator the lambda function executes without an error with all the features of the decorators.
Current Behavior
This is probably a follow up to #1481
When the @idempotent
decorator is used with other powertools decorators such as the @tracer.captureLambdaHandler()
decorator the lambda function breaks
Code snippet
import type { EventBridgeEvent, EventBridgeHandler } from 'aws-lambda';
import { IdempotencyConfig, idempotent } from '@aws-lambda-powertools/idempotency';
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
import { Tracer } from '@aws-lambda-powertools/tracer';
const tracer = new Tracer({ serviceName: 'foobarservice' });
const persistenceStore = new DynamoDBPersistenceLayer({
tableName: 'foo-table',
keyAttr: 'partitionKey',
sortKeyAttr: 'sk',
inProgressExpiryAttr: 'inProgressExpiration',
staticPkValue: 'Idempotency#pk'
});
const config = new IdempotencyConfig({ expiresAfterSeconds: 60, eventKeyJmesPath: 'detail.deduplicationId' });
export class RequestStatusChangedListener {
private readonly logger = new MyCustomLogger();
@tracer.captureLambdaHandler()
@idempotent({ persistenceStore, config })
public async handler(event: EventBridgeEvent<string, unknown>): Promise<string> {
this.logger.debug(`Received event="${JSON.stringify(event)}".`);
return 'success';
}
}
const listener = new RequestStatusChangedListener();
export const handler: EventBridgeHandler<string, unknown, string> = listener.handler.bind(listener);
Steps to Reproduce
- Deploy the code snippet
- Add some dummy custom logger
- Invoke the lambda function
Possible Solution
No response
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
{
"errorType": "TypeError",
"errorMessage": "Cannot read properties of undefined (reading 'debug')",
"stack": [
"TypeError: Cannot read properties of undefined (reading 'debug')",
" at qg.handler (file:///var/task/index.mjs:125:1450)",
" at qg.getFunctionResult (file:///var/task/index.mjs:111:22338)",
" at qg.handle (file:///var/task/index.mjs:111:22683)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async file:///var/task/index.mjs:111:39254"
]
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped