Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

configureRequestLog example code has a bug #445

Closed
smackfu opened this issue Mar 8, 2021 · 3 comments
Closed

configureRequestLog example code has a bug #445

smackfu opened this issue Mar 8, 2021 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed stale-issue

Comments

@smackfu
Copy link
Member

smackfu commented Mar 8, 2021

🐞 Bug Report

Describe the bug

In this example code, the log parameter is defaulted to an empty object, but then line 28 references clonedLog.request.metaData which is not defined.

configureRequestLog: ({ req, log = {} }) => {
const clonedLog = JSON.parse(JSON.stringify(log));
const { cookies } = req;
clonedLog.request.metaData = {

To Reproduce

If you write a test for this code and do not not pass the log variable, then you will get the following error:

TypeError: Cannot read property 'metaData' of undefined
    at Object.configureRequestLog

Expected behavior

Example code should be valid. Possible solutions:

  1. Update the default value of log.
  2. Add a check for log.request not being defined.
  3. Remove the default value of log.
@smackfu smackfu added the bug Something isn't working label Mar 8, 2021
@oneamexbot
Copy link
Contributor

Hey @smackfu! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, you can ask in our GitHub Discussions."

@americanexpress americanexpress deleted a comment from github-actions bot Apr 9, 2021
@nellyk nellyk added help wanted Extra attention is needed good first issue Good for newcomers and removed stale-issue labels Apr 9, 2021
@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity.

@10xLaCroixDrinker
Copy link
Member

closed by #647

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed stale-issue
Projects
None yet
Development

No branches or pull requests

5 participants