Skip to content

Bug: regression when passing null as extra arg in logging methods #3613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arturldev opened this issue Feb 18, 2025 · 4 comments · Fixed by #3614
Closed

Bug: regression when passing null as extra arg in logging methods #3613

arturldev opened this issue Feb 18, 2025 · 4 comments · Fixed by #3614
Assignees
Labels
bug Something isn't working completed This item is complete and has been merged/shipped logger This item relates to the Logger Utility

Comments

@arturldev
Copy link

Expected Behavior

Minor releases should not have breaking changes and minor upgrade should be effortless (see https://docs.npmjs.com/about-semantic-versioning).

The following code:

logger.info('Hello World', null);

Works fine in version 2.13.1 and below, but breaks in version 2.14.0 and throws an error:

TypeError: Cannot convert undefined or null to object

Current Behavior

logger.info('Hello World', null);

Throws an error:

TypeError: Cannot convert undefined or null to object

Code snippet

logger.info('Hello World', null);

Steps to Reproduce

logger.info('Hello World', null);

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

2.14.0

AWS Lambda function runtime

20.x

Packaging format used

Lambda Layers

Execution logs

{     "errorType": "TypeError",     "errorMessage": "Cannot convert undefined or null to object",     "stack": [         "TypeError: Cannot convert undefined or null to object",         "    at Function.entries (<anonymous>)",         "    at #processExtraObject (/opt/nodejs/node_modules/@aws-lambda-powertools/logger/lib/cjs/Logger.js:678:43)",         "    at #processExtraInput (/opt/nodejs/node_modules/@aws-lambda-powertools/logger/lib/cjs/Logger.js:670:41)",         "    at Logger.createAndPopulateLogItem (/opt/nodejs/node_modules/@aws-lambda-powertools/logger/lib/cjs/Logger.js:624:32)",         "    at Logger.processLogItem (/opt/nodejs/node_modules/@aws-lambda-powertools/logger/lib/cjs/Logger.js:780:46)",         " at Logger.debug (/opt/nodejs/node_modules/@aws-lambda-powertools/logger/lib/cjs/Logger.js:256:14)"
@arturldev arturldev added bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Feb 18, 2025
Copy link

boring-cyborg bot commented Feb 18, 2025

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@dreamorosi
Copy link
Contributor

Hi @arturldev, thank you for reporting this. I have tried the case you described and was able to confirm the regression.

I have already opened a PR to handle this case, which will correct the regression in the next release (ETA 25/02). In the meanwhile I would suggest reverting back to v2.13.1 or its corresponding Lambda layer version v19.

This was not an intended change but rather a regression in behavior caused by a bug we introduced. For this to be a breaking change, it would have needed to be intentional - which is not the case.

We take stability between patch and minor releases seriously, but unfortunately sometimes bugs can happen when refactoring or adding new features. This regression was likely introduced in #3553, and our existing test suite did not catch it.

As mentioned I have already implemented a fix which will be merged soon and also introduced additional test cases to prevent further regression in this specific case where null or undefined are passed as extra arguments to a logger item. This is already a case that was handled at the type level and would have resulted in the key being removed anyway since we remove these values, however given that there could be cases where null still ends up as an argument we now have added a runtime check to handle it.

We regret any inconvenience this regression might have caused to you / your workload.

@dreamorosi dreamorosi added logger This item relates to the Logger Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Feb 18, 2025
@dreamorosi dreamorosi moved this from Working on it to Pending review in Powertools for AWS Lambda (TypeScript) Feb 18, 2025
@dreamorosi dreamorosi changed the title Bug: Breaking change introduced in minor release v2.14.0 Bug: regression when passing null as extra arg in logging methods Feb 18, 2025
@dreamorosi dreamorosi self-assigned this Feb 18, 2025
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (TypeScript) Feb 18, 2025
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Feb 18, 2025
Copy link
Contributor

This is now released under v2.15.0 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Feb 25, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completed This item is complete and has been merged/shipped logger This item relates to the Logger Utility
Projects
Development

Successfully merging a pull request may close this issue.

2 participants