Skip to content

Bug: Declared Idempotency Packages Do Not Match Repo Structure #1486

Closed
@brianhyder

Description

@brianhyder

Expected Behaviour

The package should allow requiring/importing the modules as described in the package.json for idempotency.

Current Behaviour

The packge.json describes exports for the root of the module, persistence, and the dynamodb persistence layer. However, the capitalization of the dynamodb persistence layer class is incorrect (DynamoDbPersistenceLayer => DynamoDBPersistenceLayer).

Uncaught Error Error: ENOENT: no such file or directory, open '/workspaces/api/lambda/service/node_modules/@aws-lambda-powertools/idempotency/lib/persistence/DynamoDbPersistenceLayer.js'
    at openSync (fs:601:3)
    at readFileSync (fs:469:35)
    at readFile (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:2574:21)
    at transformFile (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1733:25)
    at _execModule (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1662:34)
    at _loadModule (/workspaces/lambda/service/node_modules/jest-runtime/build/index.js:1223:12)
    at requireModule (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1047:12)
    at requireModuleOrMock (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1248:21)
    at eval (repl:1:53)

The package.json is also missing the now available middleware module.

Uncaught ModuleNotFoundError Error: Cannot find module '@aws-lambda-powertools/idempotency/middleware' from 'src/abc.js'
    at _throwModNotFoundError (/workspaces/api/lambda/service/node_modules/jest-resolve/build/resolver.js:491:11)
    at resolveModule (/workspaces/api/lambda/service/node_modules/jest-resolve/build/resolver.js:413:10)
    at _getVirtualMockPath (/workspaces/api/lambda/service/node_modules/jest-resolve/build/resolver.js:733:14)
    at _getAbsolutePath (/workspaces/api/lambda/service/node_modules/jest-resolve/build/resolver.js:690:14)
    at getModuleID (/workspaces/api/lambda/service/node_modules/jest-resolve/build/resolver.js:617:31)
    at _shouldMockCjs (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1984:37)
    at requireModuleOrMock (/workspaces/api/lambda/service/node_modules/jest-runtime/build/index.js:1242:14)
    at eval (repl:1:53)

Code snippet

Steps to Reproduce

const idempotency = require('@aws-lambda-powertools/idempotency');
const persistence = require('@aws-lambda-powertools/idempotency/persistence');
const DynamoDBPersistenceLayer = require('@aws-lambda-powertools/idempotency/dynamodb');
const middleware = require('@aws-lambda-powertools/idempotency/middleware');

Possible Solution

Update the package.json to have the correct capitalization and add the middle ware module to the exports declaration.

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

18.x

Packaging format used

npm

Execution logs

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedidempotencyThis item relates to the Idempotency Utility

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions